p.stmtList(n.List)
p.stmtList(n.Nbody)
- case OFALL:
- op = OXFALL
- fallthrough
+ case OFALL, OXFALL:
+ p.op(OXFALL)
- case OBREAK, OCONTINUE, OGOTO, OXFALL:
+ case OBREAK, OCONTINUE:
p.op(op)
p.exprsOrNil(n.Left, nil)
case OEMPTY:
// nothing to emit
- case OLABEL:
- p.op(OLABEL)
+ case OGOTO, OLABEL:
+ p.op(op)
p.expr(n.Left)
default:
case OXCASE:
markdcl()
n := Nod(OXCASE, nil, nil)
+ n.Xoffset = int64(block)
n.List.Set(p.exprList())
// TODO(gri) eventually we must declare variables for type switch
// statements (type switch statements are not yet exported)
// case OFALL:
// unreachable - mapped to OXFALL case below by exporter
- case OBREAK, OCONTINUE, OGOTO, OXFALL:
+ case OXFALL:
+ n := Nod(OXFALL, nil, nil)
+ n.Xoffset = int64(block)
+ return n
+
+ case OBREAK, OCONTINUE:
left, _ := p.exprsOrNil()
+ if left != nil {
+ left = newname(left.Sym)
+ }
return Nod(op, left, nil)
// case OEMPTY:
// unreachable - not emitted by exporter
- case OLABEL:
- n := Nod(OLABEL, p.expr(), nil)
- n.Left.Sym = dclstack // context, for goto restrictions
+ case OGOTO, OLABEL:
+ n := Nod(op, newname(p.expr().Sym), nil)
+ n.Sym = dclstack // context, for goto restrictions
return n
case OEND:
--- /dev/null
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package a
+
+func F1() {
+L:
+ goto L
+}
+
+func F2() {
+L:
+ for {
+ break L
+ }
+}
+
+func F3() {
+L:
+ for {
+ continue L
+ }
+}
+
+func F4() {
+ switch {
+ case true:
+ fallthrough
+ default:
+ }
+}
+
+type T struct{}
+
+func (T) M1() {
+L:
+ goto L
+}
+
+func (T) M2() {
+L:
+ for {
+ break L
+ }
+}
+
+func (T) M3() {
+L:
+ for {
+ continue L
+ }
+}
+
+func (T) M4() {
+ switch {
+ case true:
+ fallthrough
+ default:
+ }
+}
--- /dev/null
+// compiledir
+
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test cases for issue #15838, and related failures.
+// Make sure the importer correctly sets up nodes for
+// label decls, goto, continue, break, and fallthrough
+// statements.
+
+package ignored