self->on_true = ontrue;
self->on_false = onfalse;
+ if (!ast_type_adopt(self, ontrue)) {
+ ast_ternary_delete(self);
+ return NULL;
+ }
+
return self;
}
for (i = 0; i < count; ++i) {
if (!ast_compare_type(self->params[i], (ast_expression*)(func->expression.params[i]))) {
- asterror(ast_ctx(self), "invalid type for parameter %u in function call",
- (unsigned int)(i+1));
+ char texp[1024];
+ char tgot[1024];
+ ast_type_to_string(self->params[i], tgot, sizeof(tgot));
+ ast_type_to_string((ast_expression*)func->expression.params[i], texp, sizeof(texp));
+ asterror(ast_ctx(self), "invalid type for parameter %u in function call: expected %s, got %s",
+ (unsigned int)(i+1), texp, tgot);
/* we don't immediately return */
retval = false;
}
size_t len;
char *from;
- if (!opts_dump)
+ if (!opts_dump && !opts_dumpfin)
return NULL;
id = (self->labelcount++);
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 */
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;