diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-03-02 15:44:54 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-03-05 12:10:27 +0100 |
| commit | 5ef8dbdf5a63ccf7e069527dbb2493dc2ef0c319 (patch) | |
| tree | 25f38d85ac74951764770ed777033ee8ed9ac542 /pkg/compiler/check.go | |
| parent | a339951e5f3c045290340330bcea3ff4155b8334 (diff) | |
pkg/compiler: support size attribute for unions
Diffstat (limited to 'pkg/compiler/check.go')
| -rw-r--r-- | pkg/compiler/check.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go index 2a6afae3a..4dac37260 100644 --- a/pkg/compiler/check.go +++ b/pkg/compiler/check.go @@ -240,10 +240,11 @@ func (comp *compiler) checkAttributeValues() { switch n := decl.(type) { case *ast.Struct: for _, attr := range n.Attrs { - if !n.IsUnion && attr.Ident == "size" { + if attr.Ident == "size" { + _, typ, name := n.Info() if comp.structIsVarlen(n.Name.Name) { - comp.error(attr.Pos, "varlen struct %v has size attribute", - n.Name.Name) + comp.error(attr.Pos, "varlen %v %v has size attribute", + typ, name) } sz := attr.Args[0].Value if sz == 0 || sz > 1<<20 { @@ -906,7 +907,7 @@ func (comp *compiler) checkVarlen(n *ast.Struct) { // Non-varlen unions can't have varlen fields. // Non-packed structs can't have varlen fields in the middle. if n.IsUnion { - if varlen := comp.parseUnionAttrs(n); varlen { + if varlen, _ := comp.parseUnionAttrs(n); varlen { return } } else { |
