add & fix constexpr4
authorMatthias Braun <matze@braunis.de>
Thu, 7 Aug 2008 11:59:11 +0000 (11:59 +0000)
committerMatthias Braun <matze@braunis.de>
Thu, 7 Aug 2008 11:59:11 +0000 (11:59 +0000)
[r21038]

ast.c
parsetest/constexpr4.c

diff --git a/ast.c b/ast.c
index 78f3692..b3ef16c 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1514,10 +1514,17 @@ bool is_address_constant(const expression_t *expression)
                /* fallthrough */
        }
 
-       case EXPR_UNARY_CAST:
-               return is_type_pointer(skip_typeref(expression->base.type))
-                       && (is_constant_expression(expression->unary.value)
+       case EXPR_UNARY_CAST: {
+               type_t *dest = skip_typeref(expression->base.type);
+               if (!is_type_pointer(dest) &&
+                               ! (dest->kind == TYPE_ATOMIC
+                                       && (get_atomic_type_flags(dest->atomic.akind) & ATOMIC_TYPE_FLAG_INTEGER)
+                                       && (get_atomic_type_size(dest->atomic.akind) >= get_atomic_type_size(get_intptr_kind()))))
+                       return false;
+
+               return (is_constant_expression(expression->unary.value)
                        || is_address_constant(expression->unary.value));
+       }
 
        case EXPR_BINARY_ADD:
        case EXPR_BINARY_SUB: {
index 3c91acb..b020b8b 100644 (file)
@@ -1,4 +1,6 @@
-int qftol(void);
+int qftol(void) {
+       return 0;
+}
 
 static int ftolPtr = (int) qftol;