aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r--gcc/cp/constexpr.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 91d14a5..346fdfa 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1105,7 +1105,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
for (i = 0; i < nargs; ++i)
{
args[i] = cxx_eval_constant_expression (&new_ctx, CALL_EXPR_ARG (t, i),
- lval, &dummy1, &dummy2);
+ false, &dummy1, &dummy2);
if (bi_const_p)
/* For __built_in_constant_p, fold all expressions with constant values
even if they aren't C++ constant-expressions. */
@@ -1114,13 +1114,31 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
bool save_ffbcp = force_folding_builtin_constant_p;
force_folding_builtin_constant_p = true;
- new_call = fold_build_call_array_loc (EXPR_LOCATION (t), TREE_TYPE (t),
- CALL_EXPR_FN (t), nargs, args);
- /* Fold away the NOP_EXPR from fold_builtin_n. */
- new_call = fold (new_call);
+ new_call = fold_builtin_call_array (EXPR_LOCATION (t), TREE_TYPE (t),
+ CALL_EXPR_FN (t), nargs, args);
force_folding_builtin_constant_p = save_ffbcp;
- VERIFY_CONSTANT (new_call);
- return new_call;
+ if (new_call == NULL)
+ {
+ if (!*non_constant_p && !ctx->quiet)
+ {
+ new_call = build_call_array_loc (EXPR_LOCATION (t), TREE_TYPE (t),
+ CALL_EXPR_FN (t), nargs, args);
+ error ("%q+E is not a constant expression", new_call);
+ }
+ *non_constant_p = true;
+ return t;
+ }
+
+ if (!potential_constant_expression (new_call))
+ {
+ if (!*non_constant_p && !ctx->quiet)
+ error ("%q+E is not a constant expression", new_call);
+ *non_constant_p = true;
+ return t;
+ }
+
+ return cxx_eval_constant_expression (&new_ctx, new_call, lval,
+ non_constant_p, overflow_p);
}
/* TEMP is the constant value of a temporary object of type TYPE. Adjust