]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
error if the ternary operands aren't of the same type - except for the first one...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Wed, 21 Nov 2012 19:56:51 +0000 (20:56 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Wed, 21 Nov 2012 19:56:51 +0000 (20:56 +0100)
parser.c

index 525192e48f2b64b1a2114bebc25c858d56375d68..94bcc620bd141b72699a0442deb36bad48232638 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -768,6 +768,12 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
             break;
 
         case opid2('?',':'):
+            if (exprs[1]->expression.vtype != exprs[2]->expression.vtype) {
+                ast_type_to_string(exprs[1], ty1, sizeof(ty1));
+                ast_type_to_string(exprs[2], ty2, sizeof(ty2));
+                parseerror(parser, "iperands of ternary expression must have the same type, got %s and %s", ty1, ty2);
+                return false;
+            }
             if (CanConstFold1(exprs[0]))
                 out = (ConstF(0) ? exprs[1] : exprs[2]);
             else