Files
swift-mirror/test/SILOptimizer/sil_combine_alloc_stack.swift
Daniel Rodríguez Troitiño 02713705c8 [android][test] Mark sil_combine_alloc_stack as executable.
The Android CI machines cannot execute the test in the target devices. Marking the test as executable makes the test filtering know that this test needs to be executed in the target device.
2020-02-17 16:37:58 -08:00

46 lines
635 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-build-swift -O %s -o %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s
// REQUIRES: executable_test
protocol E {
func f() -> Bool
}
final class K {
deinit {
print("deinit")
}
}
struct X : E {
var x: K
func f() -> Bool { return true }
}
func g<T>(_ x : T) -> Bool {
if let y = x as? E { return y.f() }
return false
}
// CHECK that there is no use-after-free in this function.
@inline(never)
func foo(_ x: X) -> Bool {
return g(x)
}
@inline(never)
func testit() {
let x = X(x: K())
_ = foo(x)
print(x)
}
// CHECK: X(x: a.K)
// CHECK: deinit
testit()