]> Cypherpunks repositories - gostls13.git/commitdiff
gc: treat DOTMETH like DOT in escape analysis.
authorLuuk van Dijk <lvd@golang.org>
Wed, 7 Sep 2011 17:03:11 +0000 (19:03 +0200)
committerLuuk van Dijk <lvd@golang.org>
Wed, 7 Sep 2011 17:03:11 +0000 (19:03 +0200)
Fixes #2225

R=rsc, nigeltao, dave
CC=bradfitz, golang-dev, mikioh.mikioh
https://golang.org/cl/4972056

src/cmd/gc/esc.c
test/escape2.go

index 790709cff2af83cd4e21bbed16bfeca8d3bf08ab..cd1f9770e19a5a2ce589ebe1664809343a187ba6 100644 (file)
@@ -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:
index c21a188308fde66df84270e14245f04e216a1630..dbe0c690651eaabce7a4ce795d74dfa0f0042711 100644 (file)
@@ -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() {}