]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
Fixing a shadowing in ir.c
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index 907a944d02f747bd8c00439be2ee1a654b9c6757..716ba1ac4a51f031a94839c13952bbc620480de6 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1412,10 +1412,11 @@ bool ast_block_codegen(ast_block *self, ast_function *func, bool lvalue, ir_valu
 bool ast_store_codegen(ast_store *self, ast_function *func, bool lvalue, ir_value **out)
 {
     ast_expression_codegen *cgen;
-    ir_value *left, *right;
+    ir_value *left  = NULL;
+    ir_value *right = NULL;
 
     ast_value       *arr;
-    ast_value       *idx;
+    ast_value       *idx = 0;
     ast_array_index *ai = NULL;
 
     if (lvalue && self->expression.outl) {
@@ -1926,10 +1927,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 +1978,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;