mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 14:12:36 +00:00
Adding some more internal-error messages where they were missing; fixed ast_ternary_codegen to use the ast_node's type instead of the ir generated ones to avoid erroring on TYPE_NIL
This commit is contained in:
parent
a170154927
commit
26d43e650f
2 changed files with 9 additions and 4 deletions
9
ast.c
9
ast.c
|
@ -2399,15 +2399,18 @@ bool ast_ternary_codegen(ast_ternary *self, ast_function *func, bool lvalue, ir_
|
|||
/* Here, now, we need a PHI node
|
||||
* but first some sanity checking...
|
||||
*/
|
||||
if (trueval->vtype != falseval->vtype) {
|
||||
if (trueval->vtype != falseval->vtype && trueval->vtype != TYPE_NIL && falseval->vtype != TYPE_NIL) {
|
||||
/* error("ternary with different types on the two sides"); */
|
||||
compile_error(ast_ctx(self), "internal error: ternary operand types invalid");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* create PHI */
|
||||
phi = ir_block_create_phi(merge, ast_ctx(self), ast_function_label(func, "phi"), trueval->vtype);
|
||||
if (!phi)
|
||||
phi = ir_block_create_phi(merge, ast_ctx(self), ast_function_label(func, "phi"), self->expression.vtype);
|
||||
if (!phi) {
|
||||
compile_error(ast_ctx(self), "internal error: failed to generate phi node");
|
||||
return false;
|
||||
}
|
||||
ir_phi_add(phi, ontrue_out, trueval);
|
||||
ir_phi_add(phi, onfalse_out, falseval);
|
||||
|
||||
|
|
4
ir.c
4
ir.c
|
@ -772,8 +772,10 @@ bool ir_function_finalize(ir_function *self)
|
|||
}
|
||||
}
|
||||
|
||||
if (!ir_function_naive_phi(self))
|
||||
if (!ir_function_naive_phi(self)) {
|
||||
irerror(self->context, "internal error: ir_function_naive_phi failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < vec_size(self->locals); ++i) {
|
||||
ir_value *v = self->locals[i];
|
||||
|
|
Loading…
Reference in a new issue