From: Wolfgang (Blub) Bumiller Date: Wed, 21 Nov 2012 19:56:51 +0000 (+0100) Subject: error if the ternary operands aren't of the same type - except for the first one... X-Git-Tag: 0.1.9~365 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9c8dc43775285c0056ab539a436b013c7933bc76;p=xonotic%2Fgmqcc.git error if the ternary operands aren't of the same type - except for the first one of course --- diff --git a/parser.c b/parser.c index 525192e..94bcc62 100644 --- 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