]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove haslabelgoto
authorJosh Bleecher Snyder <josharian@gmail.com>
Wed, 19 Apr 2017 13:35:18 +0000 (06:35 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 20 Apr 2017 13:06:10 +0000 (13:06 +0000)
As of CL 39998, it is no longer necessary.

Fixes #19699

Change-Id: Ie1c49c8468073c6ddeb96c03668705cf81d40c98
Reviewed-on: https://go-review.googlesource.com/41051
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/typecheck.go

index 58961a8b1635164be0747e7f5ac10bb01bb823bd..03320b1407a95d33b1f5e4e9853e47a0f42c0d98 100644 (file)
@@ -3957,16 +3957,10 @@ func deadcodeslice(nn Nodes) {
                        continue
                }
                if n.Op == OIF && Isconst(n.Left, CTBOOL) {
-                       var dead *Nodes
                        if n.Left.Bool() {
-                               dead = &n.Rlist
+                               n.Rlist = Nodes{}
                        } else {
-                               dead = &n.Nbody
-                       }
-                       // TODO(mdempsky/josharian): eliminate need for haslabelgoto
-                       // by checking labels and gotos earlier. See issue 19699.
-                       if !(*dead).haslabelgoto() {
-                               *dead = Nodes{}
+                               n.Nbody = Nodes{}
                        }
                }
                deadcodeslice(n.Ninit)
@@ -3975,19 +3969,3 @@ func deadcodeslice(nn Nodes) {
                deadcodeslice(n.Rlist)
        }
 }
-
-// haslabelgoto reports whether the Nodes list contains any label or goto statements.
-func (l Nodes) haslabelgoto() bool {
-       for _, n := range l.Slice() {
-               if n == nil {
-                       continue
-               }
-               if n.Op == OLABEL || n.Op == OGOTO {
-                       return true
-               }
-               if n.Ninit.haslabelgoto() || n.Nbody.haslabelgoto() || n.List.haslabelgoto() || n.Rlist.haslabelgoto() {
-                       return true
-               }
-       }
-       return false
-}