aboutsummaryrefslogtreecommitdiff
path: root/test/escape2.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-06-25 17:28:49 -0400
committerRuss Cox <rsc@golang.org>2013-06-25 17:28:49 -0400
commit148fac79a33bf7e9be279002aa289eacad41cb8f (patch)
tree8cf3414c63884a3c727565231deeae86b132e9f4 /test/escape2.go
parenta14e143c2173e106b1155905a41f5144e1a864b7 (diff)
downloadgo-148fac79a33bf7e9be279002aa289eacad41cb8f.tar.gz
go-148fac79a33bf7e9be279002aa289eacad41cb8f.zip
cmd/gc: fix escape analysis ordering
Functions without bodies were excluded from the ordering logic, because when I wrote the ordering logic there was no reason to analyze them. But then we added //go:noescape tags that need analysis, and we didn't update the ordering logic. So in the absence of good ordering, //go:noescape only worked if it appeared before the use in the source code. Fixes #5773. R=golang-dev, r CC=golang-dev https://golang.org/cl/10570043
Diffstat (limited to 'test/escape2.go')
-rw-r--r--test/escape2.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/escape2.go b/test/escape2.go
index ba88f4b3bf..5122356bf9 100644
--- a/test/escape2.go
+++ b/test/escape2.go
@@ -1337,3 +1337,22 @@ func foo143() {
}()
}
}
+
+// issue 5773
+// Check that annotations take effect regardless of whether they
+// are before or after the use in the source code.
+
+//go:noescape
+
+func foo144a(*int)
+
+func foo144() {
+ var x int
+ foo144a(&x) // ERROR "&x does not escape"
+ var y int
+ foo144b(&y) // ERROR "&y does not escape"
+}
+
+//go:noescape
+
+func foo144b(*int)