mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-20 18:32:01 +00:00
error if the ternary operands aren't of the same type - except for the first one of course
This commit is contained in:
parent
be52ca3879
commit
9c8dc43775
1 changed files with 6 additions and 0 deletions
6
parser.c
6
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
|
||||
|
|
Loading…
Reference in a new issue