]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Fixing short-logic for 'if': it wanted to add the jump to the wrong block
authorWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 22 Nov 2012 19:04:18 +0000 (20:04 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 22 Nov 2012 19:29:55 +0000 (20:29 +0100)
ast.c

diff --git a/ast.c b/ast.c
index 907a944d02f747bd8c00439be2ee1a654b9c6757..069151283bbde3ff0cc86058954a8cd1a0d10822 100644 (file)
--- 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;