aboutsummaryrefslogtreecommitdiff
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
commit38e9b0773d486beb1d91ce018586a888bbb20e45 (patch)
treefb919a5665804832b63f22d7dbc557416daf8070 /test/escape2.go
parent0ad265d48fbdef6b8ce21cd6e067d43c19b4d2a4 (diff)
downloadgo-38e9b0773d486beb1d91ce018586a888bbb20e45.tar.gz
go-38e9b0773d486beb1d91ce018586a888bbb20e45.zip
cmd/gc: fix escape analysis of method values
R=ken2 CC=golang-dev https://golang.org/cl/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 3473e4fa45..511b74a1cc 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"
+}