builtin_nanf is const
authorMatthias Braun <matze@braunis.de>
Mon, 2 Jun 2008 15:00:19 +0000 (15:00 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 2 Jun 2008 15:00:19 +0000 (15:00 +0000)
[r19941]

ast.c

diff --git a/ast.c b/ast.c
index 77be43e..690bec4 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1546,6 +1546,26 @@ bool is_address_constant(const expression_t *expression)
        }
 }
 
+static bool is_builtin_const_call(const expression_t *expression)
+{
+       expression_t *function = expression->call.function;
+       if (function->kind != EXPR_BUILTIN_SYMBOL) {
+               return false;
+       }
+
+       symbol_t *symbol = function->builtin_symbol.symbol;
+
+       switch (symbol->ID) {
+       case T___builtin_huge_val:
+       case T___builtin_nan:
+       case T___builtin_nanf:
+       case T___builtin_nand:
+               return true;
+       }
+
+       return false;
+}
+
 bool is_constant_expression(const expression_t *expression)
 {
        switch(expression->kind) {
@@ -1565,7 +1585,6 @@ bool is_constant_expression(const expression_t *expression)
 
        case EXPR_BUILTIN_SYMBOL:
        case EXPR_BUILTIN_PREFETCH:
-       case EXPR_CALL:
        case EXPR_SELECT:
        case EXPR_VA_START:
        case EXPR_VA_ARG:
@@ -1591,6 +1610,9 @@ bool is_constant_expression(const expression_t *expression)
        case EXPR_BINARY_COMMA:
                return false;
 
+       case EXPR_CALL:
+               return is_builtin_const_call(expression);
+
        case EXPR_UNARY_NEGATE:
        case EXPR_UNARY_PLUS:
        case EXPR_UNARY_BITWISE_NEGATE: