summaryrefslogtreecommitdiff
path: root/test/escape2.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-03-20 23:53:27 -0400
committerRuss Cox <rsc@golang.org>2013-03-20 23:53:27 -0400
commitc0f6dc7a26c4f4339bd44a044a43af6f82c8369b (patch)
treedb34f0d80d1f55d52c3a26ed7994a4a045446c93 /test/escape2.go
parent98b7317607ed60f6e33e66544481f4de69135e3a (diff)
downloadgo-c0f6dc7a26c4f4339bd44a044a43af6f82c8369b.tar.gz
cmd/gc: fix escape analysis of method values
R=ken2 CC=golang-dev https://codereview.appspot.com/7518050
Diffstat (limited to 'test/escape2.go')
-rw-r--r--test/escape2.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/escape2.go b/test/escape2.go
index 3473e4fa4..511b74a1c 100644
--- a/test/escape2.go
+++ b/test/escape2.go
@@ -1303,3 +1303,25 @@ func G() {
var buf4 [10]byte // ERROR "moved to heap: buf4"
F4(buf4[:]) // ERROR "buf4 escapes to heap"
}
+
+type Tm struct {
+ x int
+}
+
+func (t *Tm) M() { // ERROR "t does not escape"
+}
+
+func foo141() {
+ var f func()
+
+ t := new(Tm) // ERROR "escapes to heap"
+ f = t.M // ERROR "t.M does not escape"
+ _ = f
+}
+
+var gf func()
+
+func foo142() {
+ t := new(Tm) // ERROR "escapes to heap"
+ gf = t.M // ERROR "t.M escapes to heap"
+}