]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add case for ODOTTYPE to escwalk
authorDavid Chase <drchase@google.com>
Thu, 30 Jul 2015 16:31:18 +0000 (12:31 -0400)
committerDavid Chase <drchase@google.com>
Thu, 30 Jul 2015 17:39:44 +0000 (17:39 +0000)
ODOTTYPE should be treated a whole lot like ODOT,
but it was missing completely from the switch in
escwalk and thus escape status did not propagate
to fields.

Since interfaces are required to trigger this bug,
the test was added to escape_iface.go.

Fixes #11931.

Change-Id: Id0383981cc4b1a160f6ad447192a112eed084538
Reviewed-on: https://go-review.googlesource.com/12921
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/compile/internal/gc/esc.go
test/escape_iface.go

index 85561cdb27625c25185560b3896aac69b95b395f..4c4455fba7add78e88663c55a894703b14dc9cb3 100644 (file)
@@ -1735,6 +1735,7 @@ func escwalk(e *EscState, level Level, dst *Node, src *Node) {
                }
 
        case ODOT,
+               ODOTTYPE,
                OSLICE,
                OSLICEARR,
                OSLICE3,
index 3bc914c8bbe90fff551b8e8377f16521a550fc33..2b1144ad2c5aa2d45c2f25832e1cd86118805b5c 100644 (file)
@@ -209,3 +209,19 @@ func efaceEscape2() {
                mdoesnotescape(x)
        }
 }
+
+type T1 struct {
+       p *int
+}
+
+type T2 struct {
+       T1 T1
+}
+
+func dotTypeEscape() *T2 { // #11931
+       var x interface{}
+       x = &T1{p: new(int)} // ERROR "new\(int\) escapes to heap" "&T1 literal does not escape"
+       return &T2{
+               T1: *(x.(*T1)), // ERROR "&T2 literal escapes to heap"
+       }
+}