aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuuk van Dijk <lvd@golang.org>2011-09-07 19:03:11 +0200
committerLuuk van Dijk <lvd@golang.org>2011-09-07 19:03:11 +0200
commitf2460a8c5797888638ee5073460580d494470939 (patch)
tree0db845fa3f8e8339cd65d6d6b6e678cc5b619d00
parente85fb2137b6e824e47a6791502900e0174a5a79e (diff)
downloadgo-f2460a8c5797888638ee5073460580d494470939.tar.gz
go-f2460a8c5797888638ee5073460580d494470939.zip
gc: treat DOTMETH like DOT in escape analysis.
Fixes #2225 R=rsc, nigeltao, dave CC=bradfitz, golang-dev, mikioh.mikioh https://golang.org/cl/4972056
-rw-r--r--src/cmd/gc/esc.c2
-rw-r--r--test/escape2.go8
2 files changed, 10 insertions, 0 deletions
diff --git a/src/cmd/gc/esc.c b/src/cmd/gc/esc.c
index 790709cff2..cd1f9770e1 100644
--- a/src/cmd/gc/esc.c
+++ b/src/cmd/gc/esc.c
@@ -398,6 +398,8 @@ escassign(Node *dst, Node *src)
case OCONVIFACE:
case OCONVNOP:
case ODOT:
+ case ODOTMETH: // treat recv.meth as a value with recv in it, only happens in ODEFER and OPROC
+ // iface.method already leaks iface in esccall, no need to put in extra ODOTINTER edge here
case ODOTTYPE:
case ODOTTYPE2:
case OSLICE:
diff --git a/test/escape2.go b/test/escape2.go
index c21a188308..dbe0c69065 100644
--- a/test/escape2.go
+++ b/test/escape2.go
@@ -127,6 +127,10 @@ func (b *Bar) AlsoNoLeak() *int { // ERROR "b does not escape"
return b.ii
}
+func goLeak(b *Bar) { // ERROR "leaking param: NAME-b"
+ go b.NoLeak()
+}
+
type Bar2 struct {
i [12]int
ii []int
@@ -395,6 +399,10 @@ func foo64(m M) { // ERROR "leaking param: NAME-m"
m.M()
}
+func foo64b(m M) { // ERROR "leaking param: NAME-m"
+ defer m.M()
+}
+
type MV int
func (MV) M() {}