aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ast/testdata
diff options
context:
space:
mode:
authorPaul Chaignon <paul.chaignon@gmail.com>2024-03-01 17:02:06 +0100
committerAleksandr Nogikh <nogikh@google.com>2024-03-01 17:12:18 +0000
commit25905f5d0a2a7883bd33491997556193582c6059 (patch)
treec794c7e216531861542cfeb66f89ae26480b819d /pkg/ast/testdata
parent83acf9e00cea13b199346aea4d72094a03cef0ca (diff)
compiler: support using int flags in field conditions
Commit ed571339c6ff ("pkg/compiler: support if[expr] attributes") added support for conditional fields in structs and unions. Conditions however cannot refer to flags, as in the following example: struct { f0 flags[some_flags, int32] f1 int32 (if[value[f0] & FLAG1]) } [packed] It will fail to compile with: flags does not refer to an integer This commit adds support for that syntax. Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Diffstat (limited to 'pkg/ast/testdata')
-rw-r--r--pkg/ast/testdata/all.txt5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/ast/testdata/all.txt b/pkg/ast/testdata/all.txt
index d04fd4992..a274b3eff 100644
--- a/pkg/ast/testdata/all.txt
+++ b/pkg/ast/testdata/all.txt
@@ -16,8 +16,11 @@ expressions {
f3 int8 (if[X & (A == B) & Z != C])
}
+intflags = 1, 2, 3, 4
+
condFields {
mask int8
+ flags flags[intflags, int8]
# Simple expressions work.
f0 int16 (if[val[mask] == SOME_CONST])
# Conditions and other attributes work together.
@@ -25,5 +28,5 @@ condFields {
# Test some more complex expressions.
f2 int16 (out, if[val[mask] & SOME_CONST == OTHER_CONST])
f3 int16 (out, if[val[mask] & SOME_CONST & OTHER_CONST == val[mask] & CONST_X])
- f4 int16 (out, if[val[mask] & SOME_CONST])
+ f4 int16 (out, if[val[flags] & SOME_CONST])
}