From 2e35bb9a19c0711162e650f3723e2dbe061051ee Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Fri, 10 Nov 2023 12:55:23 +0100 Subject: compiler: support flags as int first argument This commit adds support for the following syntax: int_flags = 1, 5, 8, 9 int32[int_flags] which is equivalent to: int_flags = 1, 5, 8, 9 flags[int_flags, int32] The second int type argument, align, is not allowed if the first argument is a flag. The compiler will also error if the first argument appears to be a flag (is ident and has no colon), but can't be found in the map of flags. Signed-off-by: Paul Chaignon --- pkg/compiler/check.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pkg/compiler/check.go') diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go index 2a14b9cc0..2369daae5 100644 --- a/pkg/compiler/check.go +++ b/pkg/compiler/check.go @@ -634,7 +634,8 @@ func (comp *compiler) collectUsedType(structs, flags, strflags map[string]bool, } return } - if desc == typeFlags { + if desc == typeFlags || + (desc == typeInt && len(t.Args) > 0 && t.Args[0].Ident != "") { flags[t.Args[0].Ident] = true return } -- cgit mrf-deployment