Commit 6d33df1d authored by Daniel Martí's avatar Daniel Martí

cmd/compile: remove redundant switch label

This label was added automatically by grind to remove gotos. As of
today, it's completely useless, as none of its uses need a label to
begin with.

While at it, remove all the redundant breaks too. Leave those that are
the single statement in a case clause body, as that's the style used
throughout std and cmd to clarify when cases are empty.

Change-Id: I3e20068b66b759614e903beab1cc9b2709b31063
Reviewed-on: https://go-review.googlesource.com/62950
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent b86fae04
...@@ -285,7 +285,6 @@ func typecheck1(n *Node, top int) *Node { ...@@ -285,7 +285,6 @@ func typecheck1(n *Node, top int) *Node {
} }
ok := 0 ok := 0
OpSwitch:
switch n.Op { switch n.Op {
// until typecheck is complete, do nothing. // until typecheck is complete, do nothing.
default: default:
...@@ -300,11 +299,9 @@ OpSwitch: ...@@ -300,11 +299,9 @@ OpSwitch:
if n.Type == nil && n.Val().Ctype() == CTSTR { if n.Type == nil && n.Val().Ctype() == CTSTR {
n.Type = types.Idealstring n.Type = types.Idealstring
} }
break OpSwitch
case ONONAME: case ONONAME:
ok |= Erv ok |= Erv
break OpSwitch
case ONAME: case ONAME:
if n.Name.Decldepth == 0 { if n.Name.Decldepth == 0 {
...@@ -312,7 +309,7 @@ OpSwitch: ...@@ -312,7 +309,7 @@ OpSwitch:
} }
if n.Etype != 0 { if n.Etype != 0 {
ok |= Ecall ok |= Ecall
break OpSwitch break
} }
if top&Easgn == 0 { if top&Easgn == 0 {
...@@ -327,7 +324,6 @@ OpSwitch: ...@@ -327,7 +324,6 @@ OpSwitch:
} }
ok |= Erv ok |= Erv
break OpSwitch
case OPACK: case OPACK:
yyerror("use of package %v without selector", n.Sym) yyerror("use of package %v without selector", n.Sym)
...@@ -505,7 +501,7 @@ OpSwitch: ...@@ -505,7 +501,7 @@ OpSwitch:
checkwidth(l.Type) checkwidth(l.Type)
} }
n.Left = nil n.Left = nil
break OpSwitch break
} }
if !t.IsPtr() { if !t.IsPtr() {
...@@ -515,12 +511,11 @@ OpSwitch: ...@@ -515,12 +511,11 @@ OpSwitch:
return n return n
} }
break OpSwitch break
} }
ok |= Erv ok |= Erv
n.Type = t.Elem() n.Type = t.Elem()
break OpSwitch
// arithmetic exprs // arithmetic exprs
case OASOP, case OASOP,
...@@ -597,7 +592,7 @@ OpSwitch: ...@@ -597,7 +592,7 @@ OpSwitch:
// the outer context gives the type // the outer context gives the type
n.Type = l.Type n.Type = l.Type
break OpSwitch break
} }
// ideal mixed with non-ideal // ideal mixed with non-ideal
...@@ -781,7 +776,6 @@ OpSwitch: ...@@ -781,7 +776,6 @@ OpSwitch:
} }
n.Type = t n.Type = t
break OpSwitch
case OCOM, OMINUS, ONOT, OPLUS: case OCOM, OMINUS, ONOT, OPLUS:
ok |= Erv ok |= Erv
...@@ -799,7 +793,6 @@ OpSwitch: ...@@ -799,7 +793,6 @@ OpSwitch:
} }
n.Type = t n.Type = t
break OpSwitch
// exprs // exprs
case OADDR: case OADDR:
...@@ -840,7 +833,6 @@ OpSwitch: ...@@ -840,7 +833,6 @@ OpSwitch:
return n return n
} }
n.Type = types.NewPtr(t) n.Type = types.NewPtr(t)
break OpSwitch
case OCOMPLIT: case OCOMPLIT:
ok |= Erv ok |= Erv
...@@ -848,7 +840,6 @@ OpSwitch: ...@@ -848,7 +840,6 @@ OpSwitch:
if n.Type == nil { if n.Type == nil {
return n return n
} }
break OpSwitch
case OXDOT, ODOT: case OXDOT, ODOT:
if n.Op == OXDOT { if n.Op == OXDOT {
...@@ -899,7 +890,7 @@ OpSwitch: ...@@ -899,7 +890,7 @@ OpSwitch:
n.Xoffset = 0 n.Xoffset = 0
n.SetClass(PFUNC) n.SetClass(PFUNC)
ok = Erv ok = Erv
break OpSwitch break
} }
if t.IsPtr() && !t.Elem().IsInterface() { if t.IsPtr() && !t.Elem().IsInterface() {
...@@ -956,8 +947,6 @@ OpSwitch: ...@@ -956,8 +947,6 @@ OpSwitch:
ok |= Erv ok |= Erv
} }
break OpSwitch
case ODOTTYPE: case ODOTTYPE:
ok |= Erv ok |= Erv
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, Erv)
...@@ -1003,8 +992,6 @@ OpSwitch: ...@@ -1003,8 +992,6 @@ OpSwitch:
} }
} }
break OpSwitch
case OINDEX: case OINDEX:
ok |= Erv ok |= Erv
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, Erv)
...@@ -1066,8 +1053,6 @@ OpSwitch: ...@@ -1066,8 +1053,6 @@ OpSwitch:
n.Op = OINDEXMAP n.Op = OINDEXMAP
} }
break OpSwitch
case ORECV: case ORECV:
ok |= Etop | Erv ok |= Etop | Erv
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, Erv)
...@@ -1091,7 +1076,6 @@ OpSwitch: ...@@ -1091,7 +1076,6 @@ OpSwitch:
} }
n.Type = t.Elem() n.Type = t.Elem()
break OpSwitch
case OSEND: case OSEND:
ok |= Etop ok |= Etop
...@@ -1127,7 +1111,6 @@ OpSwitch: ...@@ -1127,7 +1111,6 @@ OpSwitch:
n.Etype = 0 n.Etype = 0
n.Type = nil n.Type = nil
break OpSwitch
case OSLICE, OSLICE3: case OSLICE, OSLICE3:
ok |= Erv ok |= Erv
...@@ -1202,7 +1185,6 @@ OpSwitch: ...@@ -1202,7 +1185,6 @@ OpSwitch:
n.Type = nil n.Type = nil
return n return n
} }
break OpSwitch
// call and call like // call and call like
case OCALL: case OCALL:
...@@ -1295,7 +1277,7 @@ OpSwitch: ...@@ -1295,7 +1277,7 @@ OpSwitch:
typecheckaste(OCALL, n.Left, n.Isddd(), t.Params(), n.List, func() string { return fmt.Sprintf("argument to %v", n.Left) }) typecheckaste(OCALL, n.Left, n.Isddd(), t.Params(), n.List, func() string { return fmt.Sprintf("argument to %v", n.Left) })
ok |= Etop ok |= Etop
if t.NumResults() == 0 { if t.NumResults() == 0 {
break OpSwitch break
} }
ok |= Erv ok |= Erv
if t.NumResults() == 1 { if t.NumResults() == 1 {
...@@ -1311,19 +1293,17 @@ OpSwitch: ...@@ -1311,19 +1293,17 @@ OpSwitch:
n.Op = OGETG n.Op = OGETG
} }
break OpSwitch break
} }
// multiple return // multiple return
if top&(Efnstruct|Etop) == 0 { if top&(Efnstruct|Etop) == 0 {
yyerror("multiple-value %v() in single-value context", l) yyerror("multiple-value %v() in single-value context", l)
break OpSwitch break
} }
n.Type = l.Type.Results() n.Type = l.Type.Results()
break OpSwitch
case OALIGNOF, OOFFSETOF, OSIZEOF: case OALIGNOF, OOFFSETOF, OSIZEOF:
ok |= Erv ok |= Erv
if !onearg(n, "%v", n.Op) { if !onearg(n, "%v", n.Op) {
...@@ -1337,8 +1317,6 @@ OpSwitch: ...@@ -1337,8 +1317,6 @@ OpSwitch:
r.Orig = n r.Orig = n
n = &r n = &r
break OpSwitch
case OCAP, OLEN: case OCAP, OLEN:
ok |= Erv ok |= Erv
if !onearg(n, "%v", n.Op) { if !onearg(n, "%v", n.Op) {
...@@ -1389,7 +1367,6 @@ OpSwitch: ...@@ -1389,7 +1367,6 @@ OpSwitch:
} }
n.Type = types.Types[TINT] n.Type = types.Types[TINT]
break OpSwitch
case OREAL, OIMAG: case OREAL, OIMAG:
ok |= Erv ok |= Erv
...@@ -1457,7 +1434,6 @@ OpSwitch: ...@@ -1457,7 +1434,6 @@ OpSwitch:
Fatalf("unexpected Etype: %v\n", et) Fatalf("unexpected Etype: %v\n", et)
} }
n.Type = types.Types[et] n.Type = types.Types[et]
break OpSwitch
case OCOMPLEX: case OCOMPLEX:
ok |= Erv ok |= Erv
...@@ -1539,7 +1515,6 @@ OpSwitch: ...@@ -1539,7 +1515,6 @@ OpSwitch:
} }
n.Type = t n.Type = t
break OpSwitch
case OCLOSE: case OCLOSE:
if !onearg(n, "%v", n.Op) { if !onearg(n, "%v", n.Op) {
...@@ -1567,7 +1542,6 @@ OpSwitch: ...@@ -1567,7 +1542,6 @@ OpSwitch:
} }
ok |= Etop ok |= Etop
break OpSwitch
case ODELETE: case ODELETE:
args := n.List args := n.List
...@@ -1600,7 +1574,6 @@ OpSwitch: ...@@ -1600,7 +1574,6 @@ OpSwitch:
} }
args.SetSecond(assignconv(r, l.Type.Key(), "delete")) args.SetSecond(assignconv(r, l.Type.Key(), "delete"))
break OpSwitch
case OAPPEND: case OAPPEND:
ok |= Erv ok |= Erv
...@@ -1658,11 +1631,11 @@ OpSwitch: ...@@ -1658,11 +1631,11 @@ OpSwitch:
if t.Elem().IsKind(TUINT8) && args.Second().Type.IsString() { if t.Elem().IsKind(TUINT8) && args.Second().Type.IsString() {
args.SetSecond(defaultlit(args.Second(), types.Types[TSTRING])) args.SetSecond(defaultlit(args.Second(), types.Types[TSTRING]))
break OpSwitch break
} }
args.SetSecond(assignconv(args.Second(), t.Orig, "append")) args.SetSecond(assignconv(args.Second(), t.Orig, "append"))
break OpSwitch break
} }
if funarg != nil { if funarg != nil {
...@@ -1682,8 +1655,6 @@ OpSwitch: ...@@ -1682,8 +1655,6 @@ OpSwitch:
} }
} }
break OpSwitch
case OCOPY: case OCOPY:
ok |= Etop | Erv ok |= Etop | Erv
args := n.List args := n.List
...@@ -1719,7 +1690,7 @@ OpSwitch: ...@@ -1719,7 +1690,7 @@ OpSwitch:
// copy([]byte, string) // copy([]byte, string)
if n.Left.Type.IsSlice() && n.Right.Type.IsString() { if n.Left.Type.IsSlice() && n.Right.Type.IsString() {
if eqtype(n.Left.Type.Elem(), types.Bytetype) { if eqtype(n.Left.Type.Elem(), types.Bytetype) {
break OpSwitch break
} }
yyerror("arguments to copy have different element types: %L and string", n.Left.Type) yyerror("arguments to copy have different element types: %L and string", n.Left.Type)
n.Type = nil n.Type = nil
...@@ -1744,8 +1715,6 @@ OpSwitch: ...@@ -1744,8 +1715,6 @@ OpSwitch:
return n return n
} }
break OpSwitch
case OCONV: case OCONV:
ok |= Erv ok |= Erv
saveorignode(n) saveorignode(n)
...@@ -1797,8 +1766,6 @@ OpSwitch: ...@@ -1797,8 +1766,6 @@ OpSwitch:
} }
} }
break OpSwitch
case OMAKE: case OMAKE:
ok |= Erv ok |= Erv
args := n.List.Slice() args := n.List.Slice()
...@@ -1909,7 +1876,6 @@ OpSwitch: ...@@ -1909,7 +1876,6 @@ OpSwitch:
} }
n.Type = t n.Type = t
break OpSwitch
case ONEW: case ONEW:
ok |= Erv ok |= Erv
...@@ -1935,7 +1901,6 @@ OpSwitch: ...@@ -1935,7 +1901,6 @@ OpSwitch:
n.Left = l n.Left = l
n.Type = types.NewPtr(t) n.Type = types.NewPtr(t)
break OpSwitch
case OPRINT, OPRINTN: case OPRINT, OPRINTN:
ok |= Etop ok |= Etop
...@@ -1950,8 +1915,6 @@ OpSwitch: ...@@ -1950,8 +1915,6 @@ OpSwitch:
} }
} }
break OpSwitch
case OPANIC: case OPANIC:
ok |= Etop ok |= Etop
if !onearg(n, "panic") { if !onearg(n, "panic") {
...@@ -1964,7 +1927,6 @@ OpSwitch: ...@@ -1964,7 +1927,6 @@ OpSwitch:
n.Type = nil n.Type = nil
return n return n
} }
break OpSwitch
case ORECOVER: case ORECOVER:
ok |= Erv | Etop ok |= Erv | Etop
...@@ -1975,7 +1937,6 @@ OpSwitch: ...@@ -1975,7 +1937,6 @@ OpSwitch:
} }
n.Type = types.Types[TINTER] n.Type = types.Types[TINTER]
break OpSwitch
case OCLOSURE: case OCLOSURE:
ok |= Erv ok |= Erv
...@@ -1983,7 +1944,6 @@ OpSwitch: ...@@ -1983,7 +1944,6 @@ OpSwitch:
if n.Type == nil { if n.Type == nil {
return n return n
} }
break OpSwitch
case OITAB: case OITAB:
ok |= Erv ok |= Erv
...@@ -1997,13 +1957,11 @@ OpSwitch: ...@@ -1997,13 +1957,11 @@ OpSwitch:
Fatalf("OITAB of %v", t) Fatalf("OITAB of %v", t)
} }
n.Type = types.NewPtr(types.Types[TUINTPTR]) n.Type = types.NewPtr(types.Types[TUINTPTR])
break OpSwitch
case OIDATA: case OIDATA:
// Whoever creates the OIDATA node must know a priori the concrete type at that moment, // Whoever creates the OIDATA node must know a priori the concrete type at that moment,
// usually by just having checked the OITAB. // usually by just having checked the OITAB.
Fatalf("cannot typecheck interface data %v", n) Fatalf("cannot typecheck interface data %v", n)
break OpSwitch
case OSPTR: case OSPTR:
ok |= Erv ok |= Erv
...@@ -2021,22 +1979,18 @@ OpSwitch: ...@@ -2021,22 +1979,18 @@ OpSwitch:
} else { } else {
n.Type = types.NewPtr(t.Elem()) n.Type = types.NewPtr(t.Elem())
} }
break OpSwitch
case OCLOSUREVAR: case OCLOSUREVAR:
ok |= Erv ok |= Erv
break OpSwitch
case OCFUNC: case OCFUNC:
ok |= Erv ok |= Erv
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, Erv)
n.Type = types.Types[TUINTPTR] n.Type = types.Types[TUINTPTR]
break OpSwitch
case OCONVNOP: case OCONVNOP:
ok |= Erv ok |= Erv
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, Erv)
break OpSwitch
// statements // statements
case OAS: case OAS:
...@@ -2048,12 +2002,10 @@ OpSwitch: ...@@ -2048,12 +2002,10 @@ OpSwitch:
if n.Left.Op == ONAME && n.Left.IsAutoTmp() { if n.Left.Op == ONAME && n.Left.IsAutoTmp() {
n.Left.Name.Defn = n n.Left.Name.Defn = n
} }
break OpSwitch
case OAS2: case OAS2:
ok |= Etop ok |= Etop
typecheckas2(n) typecheckas2(n)
break OpSwitch
case OBREAK, case OBREAK,
OCONTINUE, OCONTINUE,
...@@ -2064,7 +2016,6 @@ OpSwitch: ...@@ -2064,7 +2016,6 @@ OpSwitch:
OVARKILL, OVARKILL,
OVARLIVE: OVARLIVE:
ok |= Etop ok |= Etop
break OpSwitch
case OLABEL: case OLABEL:
ok |= Etop ok |= Etop
...@@ -2076,7 +2027,6 @@ OpSwitch: ...@@ -2076,7 +2027,6 @@ OpSwitch:
n.Op = OEMPTY n.Op = OEMPTY
n.Left = nil n.Left = nil
} }
break OpSwitch
case ODEFER: case ODEFER:
ok |= Etop ok |= Etop
...@@ -2084,13 +2034,11 @@ OpSwitch: ...@@ -2084,13 +2034,11 @@ OpSwitch:
if !n.Left.Diag() { if !n.Left.Diag() {
checkdefergo(n) checkdefergo(n)
} }
break OpSwitch
case OPROC: case OPROC:
ok |= Etop ok |= Etop
n.Left = typecheck(n.Left, Etop|Erv) n.Left = typecheck(n.Left, Etop|Erv)
checkdefergo(n) checkdefergo(n)
break OpSwitch
case OFOR, OFORUNTIL: case OFOR, OFORUNTIL:
ok |= Etop ok |= Etop
...@@ -2106,7 +2054,6 @@ OpSwitch: ...@@ -2106,7 +2054,6 @@ OpSwitch:
n.Right = typecheck(n.Right, Etop) n.Right = typecheck(n.Right, Etop)
typecheckslice(n.Nbody.Slice(), Etop) typecheckslice(n.Nbody.Slice(), Etop)
decldepth-- decldepth--
break OpSwitch
case OIF: case OIF:
ok |= Etop ok |= Etop
...@@ -2120,7 +2067,6 @@ OpSwitch: ...@@ -2120,7 +2067,6 @@ OpSwitch:
} }
typecheckslice(n.Nbody.Slice(), Etop) typecheckslice(n.Nbody.Slice(), Etop)
typecheckslice(n.Rlist.Slice(), Etop) typecheckslice(n.Rlist.Slice(), Etop)
break OpSwitch
case ORETURN: case ORETURN:
ok |= Etop ok |= Etop
...@@ -2136,29 +2082,24 @@ OpSwitch: ...@@ -2136,29 +2082,24 @@ OpSwitch:
} }
if Curfn.Type.FuncType().Outnamed && n.List.Len() == 0 { if Curfn.Type.FuncType().Outnamed && n.List.Len() == 0 {
break OpSwitch break
} }
typecheckaste(ORETURN, nil, false, Curfn.Type.Results(), n.List, func() string { return "return argument" }) typecheckaste(ORETURN, nil, false, Curfn.Type.Results(), n.List, func() string { return "return argument" })
break OpSwitch
case ORETJMP: case ORETJMP:
ok |= Etop ok |= Etop
break OpSwitch
case OSELECT: case OSELECT:
ok |= Etop ok |= Etop
typecheckselect(n) typecheckselect(n)
break OpSwitch
case OSWITCH: case OSWITCH:
ok |= Etop ok |= Etop
typecheckswitch(n) typecheckswitch(n)
break OpSwitch
case ORANGE: case ORANGE:
ok |= Etop ok |= Etop
typecheckrange(n) typecheckrange(n)
break OpSwitch
case OTYPESW: case OTYPESW:
yyerror("use of .(type) outside type switch") yyerror("use of .(type) outside type switch")
...@@ -2169,17 +2110,14 @@ OpSwitch: ...@@ -2169,17 +2110,14 @@ OpSwitch:
ok |= Etop ok |= Etop
typecheckslice(n.List.Slice(), Erv) typecheckslice(n.List.Slice(), Erv)
typecheckslice(n.Nbody.Slice(), Etop) typecheckslice(n.Nbody.Slice(), Etop)
break OpSwitch
case ODCLFUNC: case ODCLFUNC:
ok |= Etop ok |= Etop
typecheckfunc(n) typecheckfunc(n)
break OpSwitch
case ODCLCONST: case ODCLCONST:
ok |= Etop ok |= Etop
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, Erv)
break OpSwitch
case ODCLTYPE: case ODCLTYPE:
ok |= Etop ok |= Etop
...@@ -2191,7 +2129,6 @@ OpSwitch: ...@@ -2191,7 +2129,6 @@ OpSwitch:
// could silently propagate go:notinheap). // could silently propagate go:notinheap).
yyerror("type %v must be go:notinheap", n.Left.Type) yyerror("type %v must be go:notinheap", n.Left.Type)
} }
break OpSwitch
} }
t := n.Type t := n.Type
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment