Skip to content

Commit 1e0035f

Browse files
committed
Unit test lifetime dependent diagnostics for nonescaping capture
1 parent 36b9ed4 commit 1e0035f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/SILOptimizer/lifetime_dependence_diagnostics.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ func bv_copy(_ bv: borrowing BV) -> dependsOn(bv) BV {
2222
copy bv
2323
}
2424

25+
struct NCInt: ~Copyable {
26+
var value: Int
27+
}
28+
29+
func takeClosure(_: () -> ()) {}
30+
2531
// No mark_dependence is needed for a inherited scope.
2632
//
2733
// CHECK-LABEL: sil hidden @$s4test14bv_borrow_copyyAA2BVVADYlsF : $@convention(thin) (@guaranteed BV) -> _scope(1) @owned BV {
@@ -45,3 +51,10 @@ func bv_borrow_copy(_ bv: borrowing BV) -> dependsOn(scoped bv) BV {
4551
func bv_borrow_borrow(bv: borrowing BV) -> dependsOn(scoped bv) BV {
4652
bv_borrow_copy(bv)
4753
}
54+
55+
// This already has a mark_dependence [nonescaping] before diagnostics. If it triggers diagnostics again, it will fail
56+
// because lifetime dependence does not expect a dependence directly on an 'inout' address without any 'begin_access'
57+
// marker.
58+
func ncint_capture(ncInt: inout NCInt) {
59+
takeClosure { _ = ncInt.value }
60+
}

0 commit comments

Comments
 (0)