Skip to content

Commit

Permalink
cmd/compile: add case for ODOTTYPE to escwalk
Browse files Browse the repository at this point in the history
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 golang#11931.

Change-Id: Id0383981cc4b1a160f6ad447192a112eed084538
Reviewed-on: https://go-review.googlesource.com/12921
Run-TryBot: David Chase <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Dmitry Vyukov <[email protected]>
Reviewed-by: Russ Cox <[email protected]>
  • Loading branch information
dr2chase committed Jul 30, 2015
1 parent 0bd8de1 commit 6f6bcad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cmd/compile/internal/gc/esc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,7 @@ func escwalk(e *EscState, level Level, dst *Node, src *Node) {
}

case ODOT,
ODOTTYPE,
OSLICE,
OSLICEARR,
OSLICE3,
Expand Down
16 changes: 16 additions & 0 deletions test/escape_iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit 6f6bcad

Please sign in to comment.