6
6
// (Some static/dynamic enforcement selection is done in SILGen, and some is
7
7
// deferred. That may change over time but we want the outcome to be the same).
8
8
//
9
- // Each FIXME line is a case that the current implementation misses.
10
- // The model is currently being refined, so this isn't set in stone.
11
- //
12
- // TODO: Ensure that each dynamic case is covered by
13
- // Interpreter/enforce_exclusive_access.swift.
9
+ // These tests attempt to fully cover the possibilities of reads and
10
+ // modifications to captures along with `inout` arguments on both the caller and
11
+ // callee side.
14
12
15
13
// Helper
16
14
func doOne( _ f: ( ) -> ( ) ) {
@@ -30,10 +28,8 @@ func reentrantNoescape(fn: (() -> ()) -> ()) {
30
28
}
31
29
32
30
// Error: Cannot capture nonescaping closure.
33
- // Verification disabled because it suppresses all the other errors.
34
- // disabled-note@+1{{parameter 'fn' is implicitly non-escaping}}
31
+ // This triggers an early diagnostics, so it's handled in inout_capture_disgnostics.swift.
35
32
// func reentrantCapturedNoescape(fn: (() -> ()) -> ()) {
36
- // disabled-error@+1{{closure use of non-escaping parameter 'fn' may allow it to escape}}
37
33
// let c = { fn {} }
38
34
// fn(c)
39
35
// }
@@ -314,8 +310,8 @@ func inoutReadWriteInout(x: inout Int) {
314
310
// CHECK: end_access [[ACCESS]]
315
311
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape19inoutReadWriteInoutySiz1x_tFyycfU_'
316
312
317
- // Trap on boxed read + write inout.
318
- // FIXME: Passing a captured var as inout needs dynamic enforcement .
313
+ // Traps on boxed read + write inout.
314
+ // Covered by Interpreter/enforce_exclusive_access.swift .
319
315
func readBoxWriteInout( ) {
320
316
var x = 3
321
317
let c = { _ = x }
@@ -339,12 +335,11 @@ func readBoxWriteInout() {
339
335
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape17readBoxWriteInoutyyFyycfU_'
340
336
341
337
// Error: inout cannot be captured.
342
- // Verification disabled because is suppresses other errors.
343
- //func inoutReadBoxWriteInout(x: inout Int) {
344
- // disabled-error@+1{{escaping closures can only capture inout parameters explicitly by value}}
345
- // let c = { _ = x }
346
- // doOneInout(c, &x)
347
- //}
338
+ // This triggers an early diagnostics, so it's handled in inout_capture_disgnostics.swift.
339
+ // func inoutReadBoxWriteInout(x: inout Int) {
340
+ // let c = { _ = x }
341
+ // doOneInout(c, &x)
342
+ // }
348
343
349
344
// Allow aliased noescape write + write.
350
345
func writeWrite( ) {
@@ -401,9 +396,8 @@ func inoutWriteWrite(x: inout Int) {
401
396
// CHECK: end_access [[ACCESS]]
402
397
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape010inoutWriteE0ySiz1x_tFyycfU0_'
403
398
404
- // FIXME: Trap on aliased boxed write + noescape write.
405
- //
406
- // See the note above.
399
+ // Traps on aliased boxed write + noescape write.
400
+ // Covered by Interpreter/enforce_exclusive_access.swift.
407
401
func writeWriteBox( ) {
408
402
var x = 3
409
403
let c = { x = 87 }
@@ -485,8 +479,8 @@ func inoutWriteWriteInout(x: inout Int) {
485
479
// CHECK: end_access [[ACCESS]]
486
480
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape010inoutWriteE5InoutySiz1x_tFyycfU_'
487
481
488
- // Trap on boxed write + write inout.
489
- // FIXME: Passing a captured var as inout needs dynamic enforcement .
482
+ // Traps on boxed write + write inout.
483
+ // Covered by Interpreter/enforce_exclusive_access.swift .
490
484
func writeBoxWriteInout( ) {
491
485
var x = 3
492
486
let c = { x = 42 }
@@ -510,9 +504,8 @@ func writeBoxWriteInout() {
510
504
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape18writeBoxWriteInoutyyFyycfU_'
511
505
512
506
// Error: Cannot capture inout
513
- // Verification disabled because it suppresses other errors .
507
+ // This triggers an early diagnostics, so it's handled in inout_capture_disgnostics.swift .
514
508
// func inoutWriteBoxWriteInout(x: inout Int) {
515
- // disabled-error@+1{{escaping closures can only capture inout parameters explicitly by value}}
516
509
// let c = { x = 42 }
517
510
// doOneInout(c, &x)
518
511
// }
0 commit comments