1
0
mirror of https://github.com/golang/go synced 2024-11-24 05:40:15 -07:00

cmd/compile: minor cleanup in widstruct

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>
This commit is contained in:
Josh Bleecher Snyder 2017-03-23 10:59:41 -07:00
parent 899532487f
commit 7ac2e413eb

View 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
}