You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SILOptimizer: Re-implement NPCR diagnostics in SIL pass
This fixes a test involving transitive captures of local functions,
as well as an infinite recursion possible with the old code.
Fixes <rdar://problem/34496304>.
a(b) // expected-error {{passing a non-escaping function parameter 'b' to a call to a non-escaping function parameter can allow re-entrant modification of a variable}}
5
+
}
6
+
7
+
func test0(fn:(()->())->()){
8
+
fn{fn{}} // expected-error {{passing a closure which captures a non-escaping function parameter 'fn' to a call to a non-escaping function parameter can allow re-entrant modification of a variable}}
9
+
}
10
+
11
+
func test1(fn:(()->())->()){
12
+
func foo(){
13
+
fn{fn{}} // expected-error {{passing a closure which captures a non-escaping function parameter 'fn' to a call to a non-escaping function parameter can allow re-entrant modification of a variable}}
14
+
}
15
+
}
16
+
17
+
func test2(x:inoutInt, fn:(()->())->()){
18
+
func foo(myfn:()->()){
19
+
x +=1
20
+
myfn()
21
+
}
22
+
23
+
// Make sure we only complain about calls to noescape parameters.
24
+
foo{fn{}}
25
+
}
26
+
27
+
func test3(fn:(()->())->()){
28
+
{ myfn inmyfn{fn{}}}(fn) // expected-error {{passing a closure which captures a non-escaping function parameter 'fn' to a call to a non-escaping function parameter can allow re-entrant modification of a variable}}
29
+
}
30
+
31
+
func test4(fn:(()->())->()){
32
+
func foo(){
33
+
fn{}
34
+
}
35
+
36
+
fn(foo) // expected-error {{passing a closure which captures a non-escaping function parameter 'fn' to a call to a non-escaping function parameter can allow re-entrant modification of a variable}}
returntryinner{ // expected-error {{passing a closure which captures a non-escaping function parameter 'inner' to a call to a non-escaping function parameter can allow re-entrant modification of a variable}}
0 commit comments