From: Josh Bleecher Snyder Date: Thu, 23 Mar 2017 17:59:41 +0000 (-0700) Subject: cmd/compile: minor cleanup in widstruct X-Git-Tag: go1.9beta1~1012 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7ac2e413ebc42cb2e8cac73f72a679b60f9c906b;p=gostls13.git cmd/compile: minor cleanup in widstruct Change-Id: I9e52a2c52b754568412d719b415f91a998d247fe Reviewed-on: https://go-review.googlesource.com/38467 Run-TryBot: Josh Bleecher Snyder Reviewed-by: Matthew Dempsky TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/compile/internal/gc/align.go b/src/cmd/compile/internal/gc/align.go index db5edee451..10d86f5fdb 100644 --- a/src/cmd/compile/internal/gc/align.go +++ b/src/cmd/compile/internal/gc/align.go @@ -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 }