Commit d7ec89c1 authored by Tobias Klauser's avatar Tobias Klauser Committed by Josh Bleecher Snyder

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/54610Reviewed-by: default avatarAvelino <t@avelino.xxx>
Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
parent 3b87defe
......@@ -1204,7 +1204,7 @@ func foo126() {
// loopdepth 1
var i int // ERROR "moved to heap: i$"
func() { // ERROR "foo126 func literal does not escape$"
px = &i // ERROR "&i escapes to heap$" "leaking closure reference i"
px = &i // ERROR "&i escapes to heap$" "leaking closure reference i"
}()
}
_ = px
......
......@@ -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
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment