]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: fix latent import/export issue with break/continue
authorMatthew Dempsky <mdempsky@google.com>
Wed, 25 Nov 2020 22:02:46 +0000 (14:02 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 25 Nov 2020 22:29:41 +0000 (22:29 +0000)
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>
src/cmd/compile/internal/gc/iexport.go
src/cmd/compile/internal/gc/iimport.go

index ef52e40f216782547373110136fdc411225a2634..7c42e43beead5f883ee5e8ace2d5a57098c07807 100644 (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())
index 77078c118a8d323d0a4d58a792924816155e47f7..066d956b9330cd1b105158da018468b1e460f2c8 100644 (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: