From 1c9de6763ff492153b7ce2f4a13af6fc69f87fab Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Sun, 25 Nov 2012 23:54:15 +0100 Subject: [PATCH] Same as earlier: remember the outgoing block of a condition in a ternary since it could be different due to shortened logic --- ast.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ast.c b/ast.c index 6f90b18..fb58547 100644 --- a/ast.c +++ b/ast.c @@ -2179,6 +2179,7 @@ bool ast_ternary_codegen(ast_ternary *self, ast_function *func, bool lvalue, ir_ ir_instr *phi; ir_block *cond = func->curblock; + ir_block *cond_out = NULL; ir_block *ontrue, *ontrue_out = NULL; ir_block *onfalse, *onfalse_out = NULL; ir_block *merge; @@ -2204,6 +2205,7 @@ bool ast_ternary_codegen(ast_ternary *self, ast_function *func, bool lvalue, ir_ cgen = self->cond->expression.codegen; if (!(*cgen)((ast_expression*)(self->cond), func, false, &condval)) return false; + cond_out = func->curblock; /* create on-true block */ ontrue = ir_function_create_block(ast_ctx(self), func->ir_func, ast_function_label(func, "tern_T")); @@ -2250,7 +2252,7 @@ bool ast_ternary_codegen(ast_ternary *self, ast_function *func, bool lvalue, ir_ return false; /* create if instruction */ - if (!ir_block_create_if(cond, condval, ontrue, onfalse)) + if (!ir_block_create_if(cond_out, condval, ontrue, onfalse)) return false; /* Now enter the merge block */ -- 2.39.2