]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: minor cleanup in widstruct
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 23 Mar 2017 17:59:41 +0000 (10:59 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 23 Mar 2017 19:15:51 +0000 (19:15 +0000)
Change-Id: I9e52a2c52b754568412d719b415f91a998d247fe
Reviewed-on: https://go-review.googlesource.com/38467
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

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

index db5edee4510997cc7c3a2c7c74d4a47ca4858fa6..10d86f5fdbd31b09771413d59b3b41157241d180 100644 (file)
@@ -79,7 +79,6 @@ func widstruct(errtype *Type, t *Type, o int64, flag int) int64 {
                maxalign = 1
        }
        lastzero := int64(0)
-       var w int64
        for _, f := range t.Fields().Slice() {
                if f.Type == nil {
                        // broken field, just skip it so that other valid fields
@@ -91,10 +90,6 @@ func widstruct(errtype *Type, t *Type, o int64, flag int) int64 {
                if int32(f.Type.Align) > maxalign {
                        maxalign = int32(f.Type.Align)
                }
-               if f.Type.Width < 0 {
-                       Fatalf("invalid width %d", f.Type.Width)
-               }
-               w = f.Type.Width
                if f.Type.Align > 0 {
                        o = Rnd(o, int64(f.Type.Align))
                }
@@ -115,6 +110,10 @@ func widstruct(errtype *Type, t *Type, o int64, flag int) int64 {
                        }
                }
 
+               w := f.Type.Width
+               if w < 0 {
+                       Fatalf("invalid width %d", f.Type.Width)
+               }
                if w == 0 {
                        lastzero = o
                }