From 26d43e650f1519d6a2edbee7b71abd14a5a8a139 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 31 Dec 2012 12:08:47 +0100 Subject: [PATCH] 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 --- ast.c | 9 ++++++--- ir.c | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ast.c b/ast.c index 43d770d..2a1446c 100644 --- a/ast.c +++ b/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); diff --git a/ir.c b/ir.c index 4482d1d..4e50d7f 100644 --- a/ir.c +++ b/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]; -- 2.39.2