[EXPR_UNARY_CAST] = PREC_UNARY,
[EXPR_UNARY_CAST_IMPLICIT] = PREC_UNARY,
[EXPR_UNARY_ASSUME] = PREC_PRIM,
- [EXPR_UNARY_BITFIELD_EXTRACT] = PREC_ACCESS,
[EXPR_BINARY_ADD] = PREC_PLUS,
[EXPR_BINARY_SUB] = PREC_PLUS,
case EXPR_UNARY_DEREFERENCE: fputs("*", out); break;
case EXPR_UNARY_TAKE_ADDRESS: fputs("&", out); break;
- case EXPR_UNARY_BITFIELD_EXTRACT:
- print_expression_prec(unexpr->value, prec);
- return;
-
case EXPR_UNARY_POSTFIX_INCREMENT:
print_expression_prec(unexpr->value, prec);
fputs("++", out);
}
}
+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) {
case EXPR_BUILTIN_SYMBOL:
case EXPR_BUILTIN_PREFETCH:
- case EXPR_CALL:
case EXPR_SELECT:
case EXPR_VA_START:
case EXPR_VA_ARG:
case EXPR_UNARY_POSTFIX_DECREMENT:
case EXPR_UNARY_PREFIX_INCREMENT:
case EXPR_UNARY_PREFIX_DECREMENT:
- case EXPR_UNARY_BITFIELD_EXTRACT:
case EXPR_UNARY_ASSUME: /* has VOID type */
case EXPR_UNARY_TAKE_ADDRESS:
case EXPR_UNARY_DEREFERENCE:
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: