diff options
| author | 2026-10-14 15:57:41 +0330 | |
|---|---|---|
| committer | 2026-10-14 15:57:41 +0330 | |
| commit | 2633a5ec3b1d8423b913e2d1868dfc445897d93d (patch) | |
| tree | 15ba349f1e8d95512eaa33e8d010ba4176c64fa6 /tests/conformance/4-statements | |
| parent | memdebug: accept 'memdebug scrub;' (the check compared against rt.scrub); the... (diff) | |
switch: case member(): with no names matches a tagged member by tag even when it has fields (spec 4.7.3)
Diffstat (limited to 'tests/conformance/4-statements')
| -rw-r--r-- | tests/conformance/4-statements/switch_tagged_empty_parens_with_fields.zc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/conformance/4-statements/switch_tagged_empty_parens_with_fields.zc b/tests/conformance/4-statements/switch_tagged_empty_parens_with_fields.zc new file mode 100644 index 0000000..789c650 --- /dev/null +++ b/tests/conformance/4-statements/switch_tagged_empty_parens_with_fields.zc @@ -0,0 +1,15 @@ +// expect: rect/circle/ +// spec 4.7.3: case member(): with no names matches by tag even when the member has fields +include rt; +enum shape { circle { int r; }, rect { int w; int h; }, dot }; +void t(shape* s) { + switch (s) { case circle(): rt.put_s("circle"); case rect(): rt.put_s("rect"); case dot: rt.put_s("dot"); } + rt.put_c(10); +} +fn main() { + shape* a = shape.rect(4, 5); shape* b = shape.circle(2); + t(a); t(b); + rt.free(a); rt.free(b); + return 0; +} +// zc0: skip |
