1
0
mirror of https://github.com/golang/go synced 2024-11-23 22:30:05 -07:00

[dev.regabi] cmd/compile: fix latent import/export issue with break/continue

In CL 145200, I changed OBREAK, OCONTINUE, OGOTO, and OLABEL to just
use Sym instead of Node. However, within the export data, I forgot to
update the code for OBREAK and OCONTINUE.

This isn't currently an issue because the inliner currently disallows
these anyway, but it'll be an issue in the future once we add support
for inlining them. Also, Russ independently ran into it in CL 273246.

Updates #14768.

Change-Id: I94575df59c08a750b0dce1d3ce612aba7bfeeb76
Reviewed-on: https://go-review.googlesource.com/c/go/+/273270
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Matthew Dempsky 2020-11-25 14:02:46 -08:00
parent 40f5bc4d55
commit 88e33f6ecb
2 changed files with 10 additions and 17 deletions

View File

@ -1146,18 +1146,17 @@ func (w *exportWriter) stmt(n ir.Node) {
w.op(ir.OFALL)
w.pos(n.Pos())
case ir.OBREAK, ir.OCONTINUE:
w.op(op)
w.pos(n.Pos())
w.exprsOrNil(n.Left(), nil)
case ir.OEMPTY:
// nothing to emit
case ir.OGOTO, ir.OLABEL:
case ir.OBREAK, ir.OCONTINUE, ir.OGOTO, ir.OLABEL:
w.op(op)
w.pos(n.Pos())
w.string(n.Sym().Name)
label := ""
if sym := n.Sym(); sym != nil {
label = sym.Name
}
w.string(label)
default:
base.Fatalf("exporter: CANNOT EXPORT: %v\nPlease notify gri@\n", n.Op())

View File

@ -1052,20 +1052,14 @@ func (r *importReader) node() ir.Node {
n := ir.NodAt(r.pos(), ir.OFALL, nil, nil)
return n
case ir.OBREAK, ir.OCONTINUE:
pos := r.pos()
left, _ := r.exprsOrNil()
if left != nil {
left = NewName(left.Sym())
}
return ir.NodAt(pos, op, left, nil)
// case OEMPTY:
// unreachable - not emitted by exporter
case ir.OGOTO, ir.OLABEL:
case ir.OBREAK, ir.OCONTINUE, ir.OGOTO, ir.OLABEL:
n := ir.NodAt(r.pos(), op, nil, nil)
n.SetSym(lookup(r.string()))
if label := r.string(); label != "" {
n.SetSym(lookup(label))
}
return n
case ir.OEND: