mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
These get passed to the closure body in SIL as function arguments to the entry point, so the alloc_stack necessarily has to appear inside of the value's lifetime, and the store_borrow needs to be placed after that alloc_stack.
22 lines
551 B
Swift
22 lines
551 B
Swift
// RUN: %target-swift-emit-silgen -enable-experimental-feature AddressableParameters %s | %FileCheck %s
|
|
// REQUIRES: swift_feature_AddressableParameters
|
|
struct Foo {
|
|
var x, y, z: Int
|
|
|
|
init() { fatalError() }
|
|
|
|
@_addressableSelf
|
|
func foo() {}
|
|
}
|
|
|
|
func block(_: (Int) -> ()) {}
|
|
|
|
func test() {
|
|
let x = Foo()
|
|
block { (_) in x.foo() }
|
|
}
|
|
// ensure the closure properly nests the store_borrow after the alloc_stack:
|
|
// CHECK-LABEL: sil{{.*}} @${{.*}}4test{{.*}}U_ : $
|
|
// CHECK: [[STACK:%.*]] = alloc_stack
|
|
// CHECK-NEXT: store_borrow {{.*}} to [[STACK]]
|