]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove redundant switch label
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 11 Sep 2017 19:10:43 +0000 (21:10 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 12 Sep 2017 19:39:46 +0000 (19:39 +0000)
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: Ian Lance Taylor <iant@golang.org>
src/cmd/compile/internal/gc/typecheck.go

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