diff options
author | Michael Forney <mforney@mforney.org> | 2024-03-23 11:48:47 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2024-03-23 11:48:47 -0700 |
commit | 9eda39fe46c0525dab9aa6ee76708fd4f4010bfb (patch) | |
tree | f8cf889051b7c46804a537016a21b25b5627ffc4 | |
parent | c1967460749821454d5345b6b3782370d9c5d2c6 (diff) |
Add test for unreachable statements
This used to trigger a bug.
References: https://todo.sr.ht/~mcf/cproc/80
-rw-r--r-- | test/unreachable.c | 6 | ||||
-rw-r--r-- | test/unreachable.qbe | 25 |
2 files changed, 31 insertions, 0 deletions
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 +} |