From 9eda39fe46c0525dab9aa6ee76708fd4f4010bfb Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 23 Mar 2024 11:48:47 -0700 Subject: Add test for unreachable statements This used to trigger a bug. References: https://todo.sr.ht/~mcf/cproc/80 --- test/unreachable.c | 6 ++++++ test/unreachable.qbe | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 test/unreachable.c create mode 100644 test/unreachable.qbe diff --git a/test/unreachable.c b/test/unreachable.c new file mode 100644 index 0000000..7bbeed2 --- /dev/null +++ b/test/unreachable.c @@ -0,0 +1,6 @@ +void f(int x) { + return; + switch (x) { + case 0: + } +} diff --git a/test/unreachable.qbe b/test/unreachable.qbe new file mode 100644 index 0000000..e63cd4f --- /dev/null +++ b/test/unreachable.qbe @@ -0,0 +1,25 @@ +export +function $f(w %.1) { +@start.1 + %.2 =l alloc4 4 + storew %.1, %.2 +@body.2 + ret +@dead.5 + %.3 =w loadw %.2 + jmp @switch_cond.3 +@switch_case.6 + jmp @switch_join.4 +@switch_cond.3 + %.4 =w ceqw %.3, 0 + jnz %.4, @switch_case.6, @switch_ne.7 +@switch_ne.7 + %.5 =w cultw %.3, 0 + jnz %.5, @switch_lt.8, @switch_gt.9 +@switch_lt.8 + jmp @switch_join.4 +@switch_gt.9 + jmp @switch_join.4 +@switch_join.4 + ret +} -- cgit v1.2.3