+2004-06-07 Roger Sayle <roger@eyesopen.com>
+
+ PR c/14649
+ * c-typeck.c (require_constant_value, require_constant_elements):
+ Move declarations to the top of the file.
+ (build_function_call): If we require a constant value, fold with
+ fold_initializer. If the result is a constant, and the function
+ wasn't called using __builtin_foo, issue a pedantic warning.
+ (build_unary_op): If we require a constant value, fold tree with
+ fold_initializer.
+ (build_binary_op): Use require_constant_value to determine whether
+ to call fold or fold_initializer.
+
2004-06-07 Richard Henderson <rth@redhat.com>
* gimple-low.c (struct lower_data): Add the_return_label and
message within this initializer. */
static int missing_braces_mentioned;
+static int require_constant_value;
+static int require_constant_elements;
+
static tree qualify_type (tree, tree);
static int tagged_types_tu_compatible_p (tree, tree, int);
static int comp_target_types (tree, tree, int);
result = build (CALL_EXPR, TREE_TYPE (fntype),
function, coerced_params, NULL_TREE);
TREE_SIDE_EFFECTS (result) = 1;
- result = fold (result);
+
+ if (require_constant_value)
+ {
+ result = fold_initializer (result);
+
+ if (TREE_CONSTANT (result)
+ && (name == NULL_TREE
+ || strncmp (IDENTIFIER_POINTER (name), "__builtin_", 10) != 0))
+ pedwarn_init ("initializer element is not constant");
+ }
+ else
+ result = fold (result);
if (VOID_TYPE_P (TREE_TYPE (result)))
return result;
if (argtype == 0)
argtype = TREE_TYPE (arg);
- return fold (build1 (code, argtype, arg));
+ val = build1 (code, argtype, arg);
+ return require_constant_value ? fold_initializer (val) : fold (val);
}
/* Return nonzero if REF is an lvalue valid for this language.
/* 0 if implicitly pushing constructor levels is allowed. */
int constructor_no_implicit = 0; /* 0 for C; 1 for some other languages. */
-static int require_constant_value;
-static int require_constant_elements;
-
/* DECL node for which an initializer is being read.
0 means we are reading a constructor expression
such as (struct foo) {...}. */
tree result = build (resultcode, build_type, op0, op1);
/* Treat expressions in initializers specially as they can't trap. */
- result = initializer_stack ? fold_initializer (result)
- : fold (result);
+ result = require_constant_value ? fold_initializer (result)
+ : fold (result);
if (final_type != 0)
result = convert (final_type, result);