mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-19 06:40:49 +00:00
Fixing short-logic for 'if': it wanted to add the jump to the wrong block
This commit is contained in:
parent
014ae1425e
commit
f719a81e2a
1 changed files with 2 additions and 2 deletions
4
ast.c
4
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;
|
||||
|
|
Loading…
Reference in a new issue