diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2015-02-19 16:27:32 +0300 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2015-03-28 16:15:27 +0000 |
commit | edcc062bdc35a7dd6ac5d33aa85a135b020b72a8 (patch) | |
tree | dcf12943f01cb1664af7e009e8403c8fa0875f4b /test/escape_closure.go | |
parent | 8a2545744b2662fc34c117e769f3dbd2f7167d19 (diff) | |
download | go-edcc062bdc35a7dd6ac5d33aa85a135b020b72a8.tar.gz go-edcc062bdc35a7dd6ac5d33aa85a135b020b72a8.zip |
test: add tests for escape analysis of interface conversions
The false positives (var incorrectly escapes) are marked with BAD.
Change-Id: If64fabb6ea96de44a1177d9ab12e2ccc579fe0c4
Reviewed-on: https://go-review.googlesource.com/5294
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/escape_closure.go')
-rw-r--r-- | test/escape_closure.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/escape_closure.go b/test/escape_closure.go index 73578e460f..0a5f326dd3 100644 --- a/test/escape_closure.go +++ b/test/escape_closure.go @@ -41,7 +41,7 @@ func ClosureCallArgs2() { func ClosureCallArgs3() { x := 0 // ERROR "moved to heap: x" func(p *int) { // ERROR "leaking param: p" "func literal does not escape" - sink = p + sink = p // ERROR "p escapes to heap" }(&x) // ERROR "&x escapes to heap" } @@ -57,7 +57,7 @@ func ClosureCallArgs5() { x := 0 // ERROR "moved to heap: x" sink = func(p *int) *int { // ERROR "leaking param: p to result ~r1" "func literal does not escape" return p - }(&x) // ERROR "&x escapes to heap" + }(&x) // ERROR "&x escapes to heap" "\(func literal\)\(&x\) escapes to heap" } func ClosureCallArgs6() { @@ -108,7 +108,7 @@ func ClosureCallArgs10() { func ClosureCallArgs11() { x := 0 // ERROR "moved to heap: x" defer func(p *int) { // ERROR "leaking param: p" "func literal does not escape" - sink = p + sink = p // ERROR "p escapes to heap" }(&x) // ERROR "&x escapes to heap" } @@ -143,5 +143,5 @@ func ClosureCallArgs15() { sink = func(p **int) *int { // ERROR "leaking param p content to result ~r1" "func literal does not escape" return *p // BAD: p should not escape here - }(&p) // ERROR "&p escapes to heap" + }(&p) // ERROR "&p escapes to heap" "\(func literal\)\(&p\) escapes to heap" } |