]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: checkwidthj all expressions in walk
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 28 Apr 2017 00:18:02 +0000 (17:18 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 28 Apr 2017 23:38:15 +0000 (23:38 +0000)
Instead of playing whack-a-mole finding all
the non-dowidth'd expressions that can sneak
out of the frontend and then deciding on
just the right place to handle them,
use a big hammer.

Fixes #20152

Change-Id: Id452d9e8c4e9585216bd8bf0e0004c85aba4f9f7
Reviewed-on: https://go-review.googlesource.com/42021
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/walk.go

index 9fd7e64c12f69e20c10d724380f57acb76d35efc..293e18eef09640a423a54a5c188e8062f4cd8d34 100644 (file)
@@ -461,6 +461,15 @@ func walkexpr(n *Node, init *Nodes) *Node {
                return n
        }
 
+       // Eagerly checkwidth all expressions for the back end.
+       if n.Type != nil && !n.Type.WidthCalculated() {
+               switch n.Type.Etype {
+               case TBLANK, TNIL, TIDEAL:
+               default:
+                       checkwidth(n.Type)
+               }
+       }
+
        if init == &n.Ninit {
                // not okay to use n->ninit when walking n,
                // because we might replace n with some other node