commit 4143dee5add526f925872bf841776dc6c3a44c76
parent af6683cc526eacf346515c9757f80d321b5b8e22
Author: Drew DeVault <sir@cmpwn.com>
Date: Tue, 2 Feb 2021 15:54:00 -0500
gen: fix terminating switch branches
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/gen.c b/src/gen.c
@@ -1891,8 +1891,12 @@ gen_expr_switch(struct gen_context *ctx,
pushi(ctx->current, NULL, Q_JMP, &fbranch, NULL);
push(&ctx->current->body, &tlabel);
- gen_expression(ctx, _case->value, out);
- pushi(ctx->current, NULL, Q_JMP, &obranch, NULL);
+ if (_case->value->terminates) {
+ gen_expression(ctx, _case->value, NULL);
+ } else {
+ gen_expression(ctx, _case->value, out);
+ pushi(ctx->current, NULL, Q_JMP, &obranch, NULL);
+ }
push(&ctx->current->body, &flabel);
}