Skip to content

Commit e875dab

Browse files
committed
Added a negative test.
1 parent d6a821d commit e875dab

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: not --crash %target-sil-opt -enable-sil-verify-all -enforce-exclusivity=unchecked -diagnose-static-exclusivity %s 2> %t/err.txt
3+
// RUN: %FileCheck %s < %t/err.txt
4+
5+
// REQUIRES: asserts
6+
7+
// The test in this file is meant to fail during verification which currently
8+
// only runs in the diagnose-static-exclusivity pass, but will eventually run in
9+
// SIL verification.
10+
11+
import Builtin
12+
import Swift
13+
14+
// CHECK: Argument must be @noescape function type: %{{.*}} = partial_apply
15+
// CHECK: A partial_apply with @inout_aliasable may only be used as a @noescape function type argument.
16+
17+
sil @takesEscapingClosure : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
18+
19+
sil hidden @closureWithArgument : $@convention(thin) (@inout_aliasable Int) -> () {
20+
bb0(%1 : $*Int):
21+
%3 = tuple ()
22+
return %3 : $()
23+
}
24+
25+
sil @missingNoescape : $@convention(thin) (Int) ->() {
26+
bb0(%0 : $Int):
27+
%2 = alloc_box ${ var Int }
28+
%3 = project_box %2 : ${ var Int }, 0
29+
store %0 to [trivial] %3 : $*Int
30+
%4 = function_ref @takesEscapingClosure : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
31+
%5 = function_ref @closureWithArgument : $@convention(thin) (@inout_aliasable Int) -> ()
32+
%6 = partial_apply %5(%3) : $@convention(thin) (@inout_aliasable Int) -> ()
33+
%8 = apply %4(%6) : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
34+
%9 = tuple ()
35+
return %9 : $()
36+
}

0 commit comments

Comments
 (0)