summaryrefslogtreecommitdiff
path: root/test/escape2n.go
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2017-08-10 12:58:10 +0200
committerJosh Bleecher Snyder <josharian@gmail.com>2017-08-11 00:56:21 +0000
commitd7ec89c19846d8c1d89d510cd7634ae9de640ac0 (patch)
tree494888fb3bb030d3928e011e2367270517649405 /test/escape2n.go
parent3b87defe4e3f865862cbe2e0627d94a8c456ae0c (diff)
downloadgo-git-d7ec89c19846d8c1d89d510cd7634ae9de640ac0.tar.gz
test: add missing escape analysis test
https://golang.org/cl/37508 added an escape analysis test for #12397 to escape2.go but missed to add it to escape2n.go. The comment at the top of the former states that the latter should contain all the same tests and the tests only differ in using -N to compile. Conform to this by adding the function issue12397 to escape2n.go as well. Also fix a whitespace difference in escape2.go, so the two files match exactly (except for the comment at the top). Change-Id: I3a09cf95169bf2150a25d6b4ec9e147265d36760 Reviewed-on: https://go-review.googlesource.com/54610 Reviewed-by: Avelino <t@avelino.xxx> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'test/escape2n.go')
-rw-r--r--test/escape2n.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/escape2n.go b/test/escape2n.go
index 74f6f8dd65..b1130d3c3c 100644
--- a/test/escape2n.go
+++ b/test/escape2n.go
@@ -1824,3 +1824,18 @@ func issue11387(x int) func() int {
copy(slice2, slice1)
return slice2[0]
}
+
+func issue12397(x, y int) { // ERROR "moved to heap: y$"
+ // x does not escape below, because all relevant code is dead.
+ if false {
+ gxx = &x
+ } else {
+ gxx = &y // ERROR "&y escapes to heap$"
+ }
+
+ if true {
+ gxx = &y // ERROR "&y escapes to heap$"
+ } else {
+ gxx = &x
+ }
+}