commit aa33ee219911e2070c31270372eac51344ad6d31
parent 345b92503b00b4e528d5b3a4e57c9699ae0147f5
Author: Drew DeVault <sir@cmpwn.com>
Date: Thu, 11 Mar 2021 12:20:21 -0500
gen: discard out on terminating if branches
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/gen.c b/src/gen.c
@@ -1825,14 +1825,16 @@ gen_expr_if(struct gen_context *ctx,
pushi(ctx->current, NULL, Q_JNZ, &cond, &tbranch, &fbranch, NULL);
push(&ctx->current->body, &tlabel);
- gen_expression(ctx, expr->_if.true_branch, out);
+ gen_expression(ctx, expr->_if.true_branch,
+ expr->_if.true_branch->terminates ? NULL : out);
if (!expr->_if.true_branch->terminates) {
pushi(ctx->current, NULL, Q_JMP, &end, NULL);
}
push(&ctx->current->body, &flabel);
if (expr->_if.false_branch) {
- gen_expression(ctx, expr->_if.false_branch, out);
+ gen_expression(ctx, expr->_if.false_branch,
+ expr->_if.false_branch->terminates ? NULL : out);
if (!expr->_if.false_branch->terminates) {
pushi(ctx->current, NULL, Q_JMP, &end, NULL);
}