Rate EXPR_REFERENCE (variable uses) with error type as EXPR_CLASS_ERROR instead of...
authorChristoph Mallon <christoph.mallon@gmx.de>
Thu, 17 Feb 2011 13:45:49 +0000 (13:45 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Thu, 17 Feb 2011 13:45:49 +0000 (13:45 +0000)
For "case unknown_var:" this prevents the subsequent error that the case label is not constant.

[r28393]

ast.c

diff --git a/ast.c b/ast.c
index 166586e..f256e13 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1833,7 +1833,6 @@ expression_classification_t is_constant_expression(const expression_t *expressio
        case EXPR_VA_ARG:
        case EXPR_VA_COPY:
        case EXPR_STATEMENT:
-       case EXPR_REFERENCE:
        case EXPR_UNARY_POSTFIX_INCREMENT:
        case EXPR_UNARY_POSTFIX_DECREMENT:
        case EXPR_UNARY_PREFIX_INCREMENT:
@@ -1858,6 +1857,11 @@ expression_classification_t is_constant_expression(const expression_t *expressio
        case EXPR_ARRAY_ACCESS:
                return EXPR_CLASS_VARIABLE;
 
+       case EXPR_REFERENCE: {
+               type_t *const type = skip_typeref(expression->base.type);
+               return is_type_valid(type) ? EXPR_CLASS_VARIABLE : EXPR_CLASS_ERROR;
+       }
+
        case EXPR_UNARY_TAKE_ADDRESS:
                return is_object_with_constant_address(expression->unary.value);