diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2015-12-16 19:17:46 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2015-12-17 14:38:46 +0100 |
| commit | 06e67265374faa677dba2dbd2577054278f19823 (patch) | |
| tree | 2698edb0c8b9246ddfe7bb33e100fbbe03a91791 /sys/decl.go | |
| parent | 41126671ec27a77199594ba0122f95612a0e059d (diff) | |
sys: fix typos
Diffstat (limited to 'sys/decl.go')
| -rw-r--r-- | sys/decl.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/decl.go b/sys/decl.go index c591c65fb..60c076d8a 100644 --- a/sys/decl.go +++ b/sys/decl.go @@ -361,7 +361,10 @@ type ArrayType struct { } func (t ArrayType) Size() uintptr { - return 0 // for trailing embed arrays + if t.Len == 0 { + return 0 // for trailing embed arrays + } + return t.Len * t.Type.Size() } func (t ArrayType) Align() uintptr { @@ -481,7 +484,9 @@ func addAlignment(t StructType) Type { } off += f.Size() fields = append(fields, f) - _, varLen := f.(ArrayType) + if at, ok := f.(ArrayType); ok && at.Len == 0 { + varLen = true + } if varLen && i != len(t.Fields)-1 { panic("embed array in middle of a struct") } |
