]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.c
nil in ternary, and fix ternary to honor -fcorrect-logic/-ftrue/false-empty-strings
[xonotic/gmqcc.git] / parser.c
index 8fe2c31ffb36518247f6718240194e45c5996230..56b060b14d3a8c772905174e897e3445e7db0e4e 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -983,14 +983,14 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
                 return false;
             }
             vec_pop(parser->pot);
-            if (exprs[1]->expression.vtype != exprs[2]->expression.vtype) {
+            if (!ast_compare_type(exprs[1], exprs[2])) {
                 ast_type_to_string(exprs[1], ty1, sizeof(ty1));
                 ast_type_to_string(exprs[2], ty2, sizeof(ty2));
                 parseerror(parser, "operands 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]);
+                out = (immediate_is_true(ctx, asvalue[0]) ? exprs[1] : exprs[2]);
             else
                 out = (ast_expression*)ast_ternary_new(ctx, exprs[0], exprs[1], exprs[2]);
             break;