Skip to content

Commit 8216287

Browse files
committed
Update lifetime_dependence unit tests.
1 parent ecf2e36 commit 8216287

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

test/SILOptimizer/lifetime_dependence_inherit.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ struct NE {
3737
return self
3838
}
3939
}
40+
41+
// Test lifetime inheritance through chained consumes.
42+
//
43+
// This requires an inherit_lifetime marker on the argument.
44+
func bv_derive(bv: consuming BV) -> _consume(bv) BV {
45+
bv.derive()
46+
}

test/SILOptimizer/lifetime_dependence_inherit_fail.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,3 @@ struct NE {
3636
return self
3737
}
3838
}
39-
40-
func bv_derive_local(bv: consuming BV) -> _consume(bv) BV {
41-
let bv2 = BV(bv.p, bv.i)
42-
return bv2.derive() // expected-error {{lifetime-dependent value escapes its scope}}
43-
// expected-note @-2 {{it depends on the lifetime of variable 'bv2'}}
44-
// expected-note @-2 {{this use causes the lifetime-dependent value to escape}}
45-
}

test/SILOptimizer/lifetime_dependence_todo.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ func bv_get_mutate(container: inout NC) -> _mutate(container) BV {
1919
container.getBV()
2020
}
2121

22-
// Test lifetime inheritance through chained consumes.
22+
// =============================================================================
23+
// Diagnostics that should fail.
24+
25+
// Test that an unsafe dependence requires Builtin.lifetime_dependence.
2326
//
24-
// This requires an inherit_lifetime marker on the argument.
25-
func bv_derive(bv: consuming BV) -> _consume(bv) BV {
26-
bv.derive()
27+
func bv_derive_local(bv: consuming BV) -> _consume(bv) BV {
28+
let bv2 = BV(bv.p, bv.i)
29+
return bv2.derive() // expected-error {{lifetime-dependent value escapes its scope}}
30+
// expected-note @-2 {{it depends on the lifetime of variable 'bv2'}}
31+
// expected-note @-2 {{this use causes the lifetime-dependent value to escape}}
2732
}
2833

2934
// =============================================================================

0 commit comments

Comments
 (0)