]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Adding some more internal-error messages where they were missing; fixed ast_ternary_c...
authorWolfgang Bumiller <blub@speed.at>
Mon, 31 Dec 2012 11:08:47 +0000 (12:08 +0100)
committerWolfgang Bumiller <blub@speed.at>
Mon, 31 Dec 2012 11:08:47 +0000 (12:08 +0100)
ast.c
ir.c

diff --git a/ast.c b/ast.c
index 43d770d8da44ca389c759d3feee3cac010d0b6b2..2a1446c739933813ebb4d96be94ff122b0bab6a1 100644 (file)
--- 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 4482d1d40b7e3371c994dc9c424755437d280980..4e50d7f26b31db9c477d30de31ef90a94bfb5a2a 100644 (file)
--- 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];