Two places did not respect, that the true expression of ?: may be missing.
authorChristoph Mallon <christoph.mallon@gmx.de>
Thu, 18 Dec 2008 08:08:17 +0000 (08:08 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Thu, 18 Dec 2008 08:08:17 +0000 (08:08 +0000)
[r24768]

ast.c
parser.c

diff --git a/ast.c b/ast.c
index 78ff46a..beee55d 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1985,10 +1985,12 @@ bool is_constant_expression(const expression_t *expression)
                        return false;
 
                long val = fold_constant(condition);
-               if (val != 0)
-                       return is_constant_expression(expression->conditional.true_expression);
-               else
+               if (val != 0) {
+                       expression_t const *const t = expression->conditional.true_expression;
+                       return t == NULL || is_constant_expression(t);
+               } else {
                        return is_constant_expression(expression->conditional.false_expression);
+               }
        }
 
        case EXPR_INVALID:
index 25dddd4..b8d2ebe 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -9379,9 +9379,10 @@ static bool expression_has_effect(const expression_t *const expr)
                /* Generate the warning if either the left or right hand side of a
                 * conditional expression has no effect */
                case EXPR_CONDITIONAL: {
-                       const conditional_expression_t *const cond = &expr->conditional;
+                       conditional_expression_t const *const cond = &expr->conditional;
+                       expression_t             const *const t    = cond->true_expression;
                        return
-                               expression_has_effect(cond->true_expression) &&
+                               (t == NULL || expression_has_effect(t)) &&
                                expression_has_effect(cond->false_expression);
                }