diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-12-05 14:46:00 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-02-19 11:54:01 +0000 |
| commit | ed571339c6ff5ed764283737a0aa68451085e84d (patch) | |
| tree | f809f9dcd1782d7b281d2bb6b60fb3be5fa8704f /pkg/compiler/testdata/errors2.txt | |
| parent | e59ec59b027f921a6bfbe5014b15c2a802445ada (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/errors2.txt')
| -rw-r--r-- | pkg/compiler/testdata/errors2.txt | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/pkg/compiler/testdata/errors2.txt b/pkg/compiler/testdata/errors2.txt index d08f3e01e..0f10ea278 100644 --- a/pkg/compiler/testdata/errors2.txt +++ b/pkg/compiler/testdata/errors2.txt @@ -447,3 +447,64 @@ foo$non_minimizable_via_union(a ptr[in, union_non_minimizable]) (no_generate) ## resource for_fmt[int32] foo$fmt_copyin(a ptr[in, fmt[dec, for_fmt]]) foo$fmt_copyout(a ptr[out, fmt[dec, for_fmt]]) ### resource for_fmt cannot be created in fmt + + +define FLAG1 1 +define FLAG2 2 + +some_nested_nested_flags { + f4 int32 +} + +some_nested_flags { + f1 int32 + f2 array[some_nested_nested_flags] + f4 for_fmt + f5 int32 (if[value[f1] == 0]) + f6 some_nested_nested_flags +} [packed] + +conditional_fields { + f1 int32 + f2 some_nested_flags (if[value[f1] & FLAG1]) + f3 some_nested_flags + f4 int32 (if[value[f3:f1] != 0]) + f5 int32 (if[value[f3:f2:f4] != 0]) ### value path f2 does not refer to a struct + f6 int32 (if[value[f3:f4] != 0]) ### f4 does not refer to an integer + f7 int32 (if[value[f3:some_field] != 0]) ### value target some_field does not exist in some_nested_flags + f8 int32 (if[value[f3:f5] != 0]) ### f5 has conditions, so value path cannot reference it + f9 int32 (if[value[parent:a] != 0]) ### value target a does not exist in conditional_fields + f10 int32 (if[value[f3:f6] != 0]) ### f6 does not refer to an integer + f11 len[f2, int32] ### f2 has conditions, so len path cannot reference it + f12 union_cond_fields + f13 int32:8 (if[1]) ### bitfields may not have conditions +} [packed] + +union_cond_fields [ + u1 int32 (if[value[parent:parent:f1] != 0]) + u2 int32 (if[value[parent:parent:unknown] != 0]) ### value target unknown does not exist in conditional_fields + u3 int64 +] + +foo$conditional(a ptr[in, conditional_fields]) + +conditional_non_packed { + f0 int64 + f1 conditional_non_packed_nested ### variable size field f1 in the middle of non-packed struct conditional_non_packed + f2 int64 +} + +conditional_non_packed_nested { + f3 int64 (if[value[parent:parent:f0]]) + f4 int32 +} [packed] + +foo$conditional2(a ptr[in, conditional_non_packed]) + +conditional_non_packed2 { + f0 int64 + f1 int8 (if[value[f0] == 0]) ### variable size field f1 in the middle of non-packed struct conditional_non_packed2 + f2 int64 +} + +foo$conditional3(a ptr[in, conditional_non_packed2]) |
