]> Cypherpunks.ru repositories - gostls13.git/blobdiff - test/escape_closure.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / escape_closure.go
index bd6c025476ee8a8ddaff4933b715aa9bf999f2c8..0b19d6f6e8fc9020bb5549ff80da1db38fcfd23e 100644 (file)
@@ -177,3 +177,17 @@ func ClosureIndirect() {
 }
 
 func nopFunc(p *int) {} // ERROR "p does not escape"
+
+func ClosureIndirect2() {
+       f := func(p *int) *int { return p } // ERROR "leaking param: p to result ~r0 level=0" "func literal does not escape"
+
+       f(new(int)) // ERROR "new\(int\) does not escape"
+
+       g := f
+       g(new(int)) // ERROR "new\(int\) does not escape"
+
+       h := nopFunc2
+       h(new(int)) // ERROR "new\(int\) does not escape"
+}
+
+func nopFunc2(p *int) *int { return p } // ERROR "leaking param: p to result ~r0 level=0"