From f719a81e2ad5b2c124f16caafbd075bc803bb632 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Thu, 22 Nov 2012 20:04:18 +0100 Subject: [PATCH] Fixing short-logic for 'if': it wanted to add the jump to the wrong block --- ast.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ast.c b/ast.c index 907a944..0691512 100644 --- a/ast.c +++ b/ast.c @@ -1926,10 +1926,11 @@ bool ast_ifthen_codegen(ast_ifthen *self, ast_function *func, bool lvalue, ir_va self->expression.outr = (ir_value*)1; /* generate the condition */ - func->curblock = cond; cgen = self->cond->expression.codegen; if (!(*cgen)((ast_expression*)(self->cond), func, false, &condval)) return false; + /* update the block which will get the jump - because short-logic or ternaries may have changed this */ + cond = func->curblock; /* on-true path */ @@ -1976,7 +1977,6 @@ bool ast_ifthen_codegen(ast_ifthen *self, ast_function *func, bool lvalue, ir_va merge = ir_function_create_block(func->ir_func, ast_function_label(func, "endif")); if (!merge) return false; - /* add jumps ot the merge block */ if (ontrue && !ontrue_endblock->final && !ir_block_create_jump(ontrue_endblock, merge)) return false; -- 2.39.2