aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler/testdata/errors.txt
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-12-05 14:46:00 +0100
committerAleksandr Nogikh <nogikh@google.com>2024-02-19 11:54:01 +0000
commited571339c6ff5ed764283737a0aa68451085e84d (patch)
treef809f9dcd1782d7b281d2bb6b60fb3be5fa8704f /pkg/compiler/testdata/errors.txt
parente59ec59b027f921a6bfbe5014b15c2a802445ada (diff)
pkg/compiler: support if[expr] attributes
The expression may either include integers/consts or reference other fields in the structure via value[field1:field2:field3]. The fields on this path must all belong to structures and must not have any if conditions themselves. For unions, mandate that the last field has no conditions (it will be the default one). For structs, convert conditional fields into fields of a union type of the following form: anonymous_union [ value T (if[expression]) void void ]
Diffstat (limited to 'pkg/compiler/testdata/errors.txt')
-rw-r--r--pkg/compiler/testdata/errors.txt37
1 files changed, 37 insertions, 0 deletions
diff --git a/pkg/compiler/testdata/errors.txt b/pkg/compiler/testdata/errors.txt
index 1be1bd070..4f3186698 100644
--- a/pkg/compiler/testdata/errors.txt
+++ b/pkg/compiler/testdata/errors.txt
@@ -470,3 +470,40 @@ union$directions [
compressed$test(a int32) compressed_image ### compressed_image can't be syscall return
+
+define FLAG1 = 1
+define FLAG2 = 2
+
+some_nested_flags {
+ f1 int32
+}
+
+conditional_fields {
+ f1 int32
+ f2 some_nested_flags (if[value[f1] & FLAG1])
+ f3 some_nested_flags (if[value[f1] & FLAG1], if[value[f1] & FLAG1]) ### duplicate arg/field f3 attribute if
+ f4 some_nested_flags (if[value & FLAG1]) ### value reference must have only one argument
+ f5 some_nested_flags (if[value[f1] & FLAG1, FLAG2]) ### if attribute is expected to have only one argument
+ f6 some_nested_flags (if[value[f1, FLAG2] & FLAG1]) ### value reference must have only one argument
+ f7 some_nested_flags (if[5])
+ f8 some_nested_flags
+ f9 some_nested_flags (if[value[f8:f1] & FLAG1])
+ f10 some_nested_flags (if[value[f8:f1, A] & FLAG1]) ### value reference must have only one argument
+ f11 some_nested_flags (if[value[f8:f1[A]] & FLAG1]) ### value aguments must not have any further arguments
+ f12 some_nested_flags (if[f1 == "A"]) ### the token must be either an integer or an identifier
+ f13 some_nested_flags (if["ABCD"]) ### if argument must be an expression
+ f14 some_nested_flags (if[X[Y]]) ### consts in expressions must not have any arguments
+ f15 conditional_fields_union1
+ f16 conditional_fields_union2
+}
+
+conditional_fields_union1 [
+ u1 int32 (if [value[parent:f1] & FLAG1])
+ u2 int32 (if [value[parent:f1] & FLAG2]) ### unions must not have if conditions on the last field
+]
+
+conditional_fields_union2 [
+ u1 int32 (if [value[parent:f1] & FLAG1])
+ u2 int32 ### either no fields have conditions or all except the last
+ u3 int32
+]