diff options
Diffstat (limited to 'tests/conformance/4-statements')
| -rw-r--r-- | tests/conformance/4-statements/memdebug_scrub_fills.zc | 4 | ||||
| -rw-r--r-- | tests/conformance/4-statements/switch_tagged_empty_parens_with_fields.zc | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/tests/conformance/4-statements/memdebug_scrub_fills.zc b/tests/conformance/4-statements/memdebug_scrub_fills.zc index ad15e3d..eed4c2d 100644 --- a/tests/conformance/4-statements/memdebug_scrub_fills.zc +++ b/tests/conformance/4-statements/memdebug_scrub_fills.zc @@ -1,10 +1,10 @@ // expect: 57005/ -// spec 4.11: memdebug scrub; fills freed payloads with 57005 +// spec 4.11: memdebug scrub; fills freed payloads with 57005 (read through asm, which the use-after-free check does not see) include rt; void pn(int x) { rt.put_n(x); rt.put_c(10); } memdebug scrub; fn main() { - unchecked { int* p = rt.new(int); *p = 5; rt.free(p); pn(*p); } + unchecked { int* p = rt.new(int); *p = 5; word a = p; rt.free(p); pn(asm { a @ @ }); } return 0; } // zc0: skip 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 |
