static bool verify_constant (tree, bool, bool *, bool *);
#define VERIFY_CONSTANT(X) \
do { \
- if (verify_constant ((X), allow_non_constant, non_constant_p, overflow_p)) \
+ if (verify_constant ((X), ctx->quiet, non_constant_p, overflow_p)) \
return t; \
} while (0)
hash_map<tree,tree> *values;
tree ctor;
tree object;
+ bool quiet;
};
/* A table of all constexpr calls that have been evaluated by the
static GTY (()) hash_table<constexpr_call_hasher> *constexpr_call_table;
static tree cxx_eval_constant_expression (const constexpr_ctx *, tree,
- bool, bool, bool *, bool *, tree *);
+ bool, bool *, bool *, tree *);
/* Compute a hash value for a constexpr call representation. */
static tree
cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
const int nargs = call_expr_nargs (t);
for (i = 0; i < nargs; ++i)
{
args[i] = cxx_eval_constant_expression (ctx, CALL_EXPR_ARG (t, i),
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p,
NULL);
- if (allow_non_constant && *non_constant_p)
+ if (ctx->quiet && *non_constant_p)
return t;
}
if (*non_constant_p)
static void
cxx_bind_parameters_in_call (const constexpr_ctx *ctx, tree t,
constexpr_call *new_call,
- bool allow_non_constant,
bool *non_constant_p, bool *overflow_p)
{
const int nargs = call_expr_nargs (t);
type = TREE_TYPE (type);
x = convert_from_reference (x);
}
- arg = cxx_eval_constant_expression (ctx, x, allow_non_constant,
+ arg = cxx_eval_constant_expression (ctx, x,
TREE_CODE (type) == REFERENCE_TYPE,
non_constant_p, overflow_p, NULL);
/* Don't VERIFY_CONSTANT here. */
- if (*non_constant_p && allow_non_constant)
+ if (*non_constant_p && ctx->quiet)
return;
/* Just discard ellipsis args after checking their constantitude. */
if (!parms)
static tree
cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
location_t loc = EXPR_LOC_OR_LOC (t, input_location);
if (TREE_CODE (fun) != FUNCTION_DECL)
{
/* Might be a constexpr function pointer. */
- fun = cxx_eval_constant_expression (ctx, fun, allow_non_constant,
+ fun = cxx_eval_constant_expression (ctx, fun,
/*addr*/false, non_constant_p,
overflow_p, NULL);
STRIP_NOPS (fun);
}
if (TREE_CODE (fun) != FUNCTION_DECL)
{
- if (!allow_non_constant && !*non_constant_p)
+ if (!ctx->quiet && !*non_constant_p)
error_at (loc, "expression %qE does not designate a constexpr "
"function", fun);
*non_constant_p = true;
if (DECL_CLONED_FUNCTION_P (fun))
fun = DECL_CLONED_FUNCTION (fun);
if (is_builtin_fn (fun))
- return cxx_eval_builtin_function_call (ctx, t, allow_non_constant,
+ return cxx_eval_builtin_function_call (ctx, t,
addr, non_constant_p, overflow_p);
if (!DECL_DECLARED_CONSTEXPR_P (fun))
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
{
error_at (loc, "call to non-constexpr function %qD", fun);
explain_invalid_constexpr_fn (fun);
if (call_expr_nargs (t) == 2)
{
tree arg = convert_from_reference (get_nth_callarg (t, 1));
- return cxx_eval_constant_expression (ctx, arg, allow_non_constant,
+ return cxx_eval_constant_expression (ctx, arg,
addr, non_constant_p,
overflow_p, NULL);
}
new_call.fundef = retrieve_constexpr_fundef (fun);
if (new_call.fundef == NULL || new_call.fundef->body == NULL)
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
{
if (DECL_INITIAL (fun))
{
}
cxx_bind_parameters_in_call (ctx, t, &new_call,
- allow_non_constant, non_constant_p, overflow_p);
+ non_constant_p, overflow_p);
if (*non_constant_p)
return t;
so that we can detect circular dependencies. */
else if (entry->result == NULL)
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("call has circular dependency");
*non_constant_p = true;
entry->result = result = error_mark_node;
if (!depth_ok)
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("constexpr evaluation depth exceeds maximum of %d (use "
"-fconstexpr-depth= to increase the maximum)",
max_constexpr_depth);
new_ctx.call = &new_call;
result = (cxx_eval_constant_expression
(&new_ctx, new_call.fundef->body,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p, NULL));
}
else
ctx->values->put (res, NULL_TREE);
tree jump_target = NULL_TREE;
- cxx_eval_constant_expression (ctx, body, allow_non_constant,
+ cxx_eval_constant_expression (ctx, body,
addr, non_constant_p, overflow_p,
&jump_target);
result = *ctx->values->get (slot ? slot : res);
if (result == NULL_TREE)
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("constexpr call flows off the end "
"of the function");
*non_constant_p = true;
static tree
cxx_eval_unary_expression (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
tree r;
tree orig_arg = TREE_OPERAND (t, 0);
- tree arg = cxx_eval_constant_expression (ctx, orig_arg, allow_non_constant,
+ tree arg = cxx_eval_constant_expression (ctx, orig_arg,
addr, non_constant_p, overflow_p,
NULL);
VERIFY_CONSTANT (arg);
static tree
cxx_eval_binary_expression (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
tree r;
tree orig_rhs = TREE_OPERAND (t, 1);
tree lhs, rhs;
lhs = cxx_eval_constant_expression (ctx, orig_lhs,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p, NULL);
VERIFY_CONSTANT (lhs);
rhs = cxx_eval_constant_expression (ctx, orig_rhs,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p, NULL);
VERIFY_CONSTANT (rhs);
static tree
cxx_eval_conditional_expression (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p,
tree *jump_target)
{
tree val = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p,
NULL);
VERIFY_CONSTANT (val);
/* Don't VERIFY_CONSTANT the other operands. */
if (integer_zerop (val))
return cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 2),
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p,
jump_target);
return cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p,
jump_target);
}
static tree
cxx_eval_array_reference (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
tree oldary = TREE_OPERAND (t, 0);
tree ary = cxx_eval_constant_expression (ctx, oldary,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p, NULL);
tree index, oldidx;
HOST_WIDE_INT i;
return t;
oldidx = TREE_OPERAND (t, 1);
index = cxx_eval_constant_expression (ctx, oldidx,
- allow_non_constant, false,
+ false,
non_constant_p, overflow_p, NULL);
VERIFY_CONSTANT (index);
if (addr && ary == oldary && index == oldidx)
initializer, it's value-initialized. */
tree val = build_value_init (elem_type, tf_warning_or_error);
return cxx_eval_constant_expression (ctx, val,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p,
NULL);
}
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("array subscript out of bound");
*non_constant_p = true;
return t;
}
else if (tree_int_cst_lt (index, integer_zero_node))
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("negative array subscript");
*non_constant_p = true;
return t;
static tree
cxx_eval_component_reference (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
unsigned HOST_WIDE_INT i;
tree part = TREE_OPERAND (t, 1);
tree orig_whole = TREE_OPERAND (t, 0);
tree whole = cxx_eval_constant_expression (ctx, orig_whole,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p, NULL);
if (whole == orig_whole)
return t;
CONSTRUCTOR. */
if (!*non_constant_p && TREE_CODE (whole) != CONSTRUCTOR)
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("%qE is not a constant expression", orig_whole);
*non_constant_p = true;
}
if (DECL_MUTABLE_P (part))
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("mutable %qD is not usable in a constant expression", part);
*non_constant_p = true;
}
&& CONSTRUCTOR_NELTS (whole) > 0)
{
/* DR 1188 says we don't have to deal with this. */
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("accessing %qD member instead of initialized %qD member in "
"constant expression", part, CONSTRUCTOR_ELT (whole, 0)->index);
*non_constant_p = true;
/* 'whole' is part of the aggregate initializer we're currently
building; if there's no initializer for this member yet, that's an
error. */
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("accessing uninitialized member %qD", part);
*non_constant_p = true;
return t;
/* If there's no explicit init for this field, it's value-initialized. */
value = build_value_init (TREE_TYPE (t), tf_warning_or_error);
return cxx_eval_constant_expression (ctx, value,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p, NULL);
}
static tree
cxx_eval_bit_field_ref (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
tree orig_whole = TREE_OPERAND (t, 0);
bool fld_seen = false;
HOST_WIDE_INT istart, isize;
tree whole = cxx_eval_constant_expression (ctx, orig_whole,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p, NULL);
tree start, field, value;
unsigned HOST_WIDE_INT i;
&& TREE_CODE (whole) != VECTOR_CST
&& TREE_CODE (whole) != CONSTRUCTOR)
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("%qE is not a constant expression", orig_whole);
*non_constant_p = true;
}
static tree
cxx_eval_logical_expression (const constexpr_ctx *ctx, tree t,
tree bailout_value, tree continue_value,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
tree r;
tree lhs = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p, NULL);
VERIFY_CONSTANT (lhs);
if (tree_int_cst_equal (lhs, bailout_value))
return lhs;
gcc_assert (tree_int_cst_equal (lhs, continue_value));
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
- allow_non_constant, addr, non_constant_p,
+ addr, non_constant_p,
overflow_p, NULL);
VERIFY_CONSTANT (r);
return r;
static tree
cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (t);
initializers can refer to it. */
CONSTRUCTOR_APPEND_ELT (*p, index, new_ctx.ctor);
tree elt = cxx_eval_constant_expression (&new_ctx, value,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p,
NULL);
/* Don't VERIFY_CONSTANT here. */
- if (allow_non_constant && *non_constant_p)
+ if (ctx->quiet && *non_constant_p)
break;
if (elt != value)
changed = true;
static tree
cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
- bool value_init, bool allow_non_constant, bool addr,
+ bool value_init, bool addr,
bool *non_constant_p, bool *overflow_p)
{
tree elttype = TREE_TYPE (atype);
eltinit = cp_build_array_ref (input_location, init, idx,
tf_warning_or_error);
eltinit = cxx_eval_vec_init_1 (&new_ctx, elttype, eltinit, value_init,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p);
}
else if (pre_init)
/* Initializing an element using value or default initialization
we just pre-built above. */
eltinit = (cxx_eval_constant_expression
- (&new_ctx, init, allow_non_constant,
+ (&new_ctx, init,
addr, non_constant_p, overflow_p, NULL));
}
else
eltinit = move (eltinit);
eltinit = force_rvalue (eltinit, tf_warning_or_error);
eltinit = (cxx_eval_constant_expression
- (&new_ctx, eltinit, allow_non_constant, addr,
+ (&new_ctx, eltinit, addr,
non_constant_p, overflow_p, NULL));
}
- if (*non_constant_p && !allow_non_constant)
+ if (*non_constant_p && !ctx->quiet)
break;
if (new_ctx.ctor != ctx->ctor)
{
static tree
cxx_eval_vec_init (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
tree atype = TREE_TYPE (t);
tree init = VEC_INIT_EXPR_INIT (t);
tree r = cxx_eval_vec_init_1 (ctx, atype, init,
VEC_INIT_EXPR_VALUE_INIT (t),
- allow_non_constant, addr, non_constant_p, overflow_p);
+ addr, non_constant_p, overflow_p);
if (*non_constant_p)
return t;
else
static tree
cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
tree orig_op0 = TREE_OPERAND (t, 0);
- tree op0 = cxx_eval_constant_expression (ctx, orig_op0, allow_non_constant,
+ tree op0 = cxx_eval_constant_expression (ctx, orig_op0,
/*addr*/false, non_constant_p,
overflow_p, NULL);
bool empty_base = false;
&empty_base);
if (r)
- r = cxx_eval_constant_expression (ctx, r, allow_non_constant,
+ r = cxx_eval_constant_expression (ctx, r,
addr, non_constant_p, overflow_p, NULL);
else
{
gcc_assert (!same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (TREE_TYPE (sub)), TREE_TYPE (t)));
/* DR 1188 says we don't have to deal with this. */
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("accessing value of %qE through a %qT glvalue in a "
"constant expression", build_fold_indirect_ref (sub),
TREE_TYPE (t));
static tree
cxx_eval_trinary_expression (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
int i;
for (i = 0; i < 3; i++)
{
args[i] = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, i),
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p,
NULL);
VERIFY_CONSTANT (args[i]);
static tree
cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
constexpr_ctx new_ctx = *ctx;
/* First we figure out where we're storing to. */
tree target = TREE_OPERAND (t, 0);
target = cxx_eval_constant_expression (ctx, target,
- allow_non_constant, true,
+ true,
non_constant_p, overflow_p, NULL);
if (*non_constant_p)
return t;
{
/* A constant-expression cannot modify objects from outside the
constant-expression. */
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("modification of %qD is not a constant-expression", object);
*non_constant_p = true;
return t;
}
tree init = cxx_eval_constant_expression (&new_ctx, TREE_OPERAND (t, 1),
- allow_non_constant, false,
+ false,
non_constant_p, overflow_p, NULL);
if (target == object)
/* The hash table might have moved since the get earlier. */
static tree
cxx_eval_increment_expression (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p)
{
enum tree_code code = TREE_CODE (t);
gcc_assert (TREE_CONSTANT (offset));
/* The operand as an lvalue. */
- op = cxx_eval_constant_expression (ctx, op, allow_non_constant, true,
+ op = cxx_eval_constant_expression (ctx, op, true,
non_constant_p, overflow_p, NULL);
/* The operand as an rvalue. */
tree val = rvalue (op);
- val = cxx_eval_constant_expression (ctx, val, allow_non_constant, false,
+ val = cxx_eval_constant_expression (ctx, val, false,
non_constant_p, overflow_p, NULL);
VERIFY_CONSTANT (val);
/* Storing the modified value. */
tree store = build2 (MODIFY_EXPR, type, op, mod);
- cxx_eval_constant_expression (ctx, store, allow_non_constant,
+ cxx_eval_constant_expression (ctx, store,
true, non_constant_p, overflow_p, NULL);
/* And the value of the expression. */
static tree
cxx_eval_statement_list (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant,
bool *non_constant_p, bool *overflow_p,
tree *jump_target)
{
continue;
}
cxx_eval_constant_expression (ctx, stmt,
- allow_non_constant, false,
+ false,
non_constant_p, overflow_p,
jump_target);
if (*non_constant_p)
static tree
cxx_eval_loop_expr (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant,
bool *non_constant_p, bool *overflow_p,
tree *jump_target)
{
tree body = TREE_OPERAND (t, 0);
while (true)
{
- cxx_eval_statement_list (ctx, body, allow_non_constant,
+ cxx_eval_statement_list (ctx, body,
non_constant_p, overflow_p, jump_target);
if (returns (jump_target) || breaks (jump_target))
break;
static tree
cxx_eval_switch_expr (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant,
bool *non_constant_p, bool *overflow_p,
tree *jump_target)
{
tree cond = TREE_OPERAND (t, 0);
- cond = cxx_eval_constant_expression (ctx, cond, allow_non_constant, false,
+ cond = cxx_eval_constant_expression (ctx, cond, false,
non_constant_p, overflow_p, NULL);
VERIFY_CONSTANT (cond);
*jump_target = cond;
tree body = TREE_OPERAND (t, 1);
- cxx_eval_statement_list (ctx, body, allow_non_constant,
+ cxx_eval_statement_list (ctx, body,
non_constant_p, overflow_p, jump_target);
if (breaks (jump_target) || switches (jump_target))
*jump_target = NULL_TREE;
static tree
cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
- bool allow_non_constant, bool addr,
+ bool addr,
bool *non_constant_p, bool *overflow_p,
tree *jump_target)
{
{
if (TREE_CODE (t) == PTRMEM_CST)
t = cplus_expand_constant (t);
- else if (TREE_OVERFLOW (t) && (!flag_permissive || allow_non_constant))
+ else if (TREE_OVERFLOW (t) && (!flag_permissive || ctx->quiet))
*overflow_p = true;
return t;
}
r = *p;
if (DECL_P (r))
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
non_const_var_error (r);
*non_constant_p = true;
}
/* Defer in case this is only used for its type. */;
else
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
error ("%qE is not a constant expression", t);
*non_constant_p = true;
}
case CALL_EXPR:
case AGGR_INIT_EXPR:
- r = cxx_eval_call_expression (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_call_expression (ctx, t, addr,
non_constant_p, overflow_p);
break;
if (tree init = DECL_INITIAL (r))
{
init = cxx_eval_constant_expression (ctx, init,
- allow_non_constant, false,
+ false,
non_constant_p, overflow_p,
NULL);
ctx->values->put (r, init);
case TARGET_EXPR:
if (!literal_type_p (TREE_TYPE (t)))
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
{
error ("temporary of non-literal type %qT in a "
"constant expression", TREE_TYPE (t));
/* Pass false for 'addr' because this indicates
initialization of a temporary. */
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
- allow_non_constant, false,
+ false,
non_constant_p, overflow_p, NULL);
if (!*non_constant_p)
/* Adjust the type of the result to the type of the temporary. */
/* In C++11 constexpr evaluation we are looking for the value,
not the side-effect of the initialization. */
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
- allow_non_constant, false,
+ false,
non_constant_p, overflow_p, NULL);
break;
}
/* else fall through */
case MODIFY_EXPR:
- r = cxx_eval_store_expression (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_store_expression (ctx, t, addr,
non_constant_p, overflow_p);
break;
case SCOPE_REF:
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p, NULL);
break;
case RETURN_EXPR:
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p, NULL);
*jump_target = t;
break;
case EXPR_STMT:
case EH_SPEC_BLOCK:
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p,
jump_target);
break;
check for a constant operand or result; an address can be
constant without its operand being, and vice versa. */
case INDIRECT_REF:
- r = cxx_eval_indirect_ref (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_indirect_ref (ctx, t, addr,
non_constant_p, overflow_p);
break;
{
tree oldop = TREE_OPERAND (t, 0);
tree op = cxx_eval_constant_expression (ctx, oldop,
- allow_non_constant,
/*addr*/true,
non_constant_p, overflow_p,
NULL);
case BIT_NOT_EXPR:
case TRUTH_NOT_EXPR:
case FIXED_CONVERT_EXPR:
- r = cxx_eval_unary_expression (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_unary_expression (ctx, t, addr,
non_constant_p, overflow_p);
break;
STRIP_NOPS (op1);
if ((TREE_CODE (op0) == TARGET_EXPR && op1 == TARGET_EXPR_SLOT (op0))
|| TREE_CODE (op1) == EMPTY_CLASS_EXPR)
- r = cxx_eval_constant_expression (ctx, op0, allow_non_constant,
+ r = cxx_eval_constant_expression (ctx, op0,
addr, non_constant_p, overflow_p,
jump_target);
else
{
/* Check that the LHS is constant and then discard it. */
- cxx_eval_constant_expression (ctx, op0, allow_non_constant,
+ cxx_eval_constant_expression (ctx, op0,
false, non_constant_p, overflow_p,
jump_target);
op1 = TREE_OPERAND (t, 1);
- r = cxx_eval_constant_expression (ctx, op1, allow_non_constant,
+ r = cxx_eval_constant_expression (ctx, op1,
addr, non_constant_p, overflow_p,
jump_target);
}
case LTGT_EXPR:
case RANGE_EXPR:
case COMPLEX_EXPR:
- r = cxx_eval_binary_expression (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_binary_expression (ctx, t, addr,
non_constant_p, overflow_p);
break;
case TRUTH_ANDIF_EXPR:
r = cxx_eval_logical_expression (ctx, t, boolean_false_node,
boolean_true_node,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p);
break;
case TRUTH_ORIF_EXPR:
r = cxx_eval_logical_expression (ctx, t, boolean_true_node,
boolean_false_node,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p);
break;
case ARRAY_REF:
- r = cxx_eval_array_reference (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_array_reference (ctx, t, addr,
non_constant_p, overflow_p);
break;
build_non_dependent_expr, because any expression that
calls or takes the address of the function will have
pulled a FUNCTION_DECL out of the COMPONENT_REF. */
- gcc_checking_assert (allow_non_constant || errorcount);
+ gcc_checking_assert (ctx->quiet || errorcount);
*non_constant_p = true;
return t;
}
- r = cxx_eval_component_reference (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_component_reference (ctx, t, addr,
non_constant_p, overflow_p);
break;
case BIT_FIELD_REF:
- r = cxx_eval_bit_field_ref (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_bit_field_ref (ctx, t, addr,
non_constant_p, overflow_p);
break;
case COND_EXPR:
case VEC_COND_EXPR:
- r = cxx_eval_conditional_expression (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_conditional_expression (ctx, t, addr,
non_constant_p, overflow_p,
jump_target);
break;
case CONSTRUCTOR:
- r = cxx_eval_bare_aggregate (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_bare_aggregate (ctx, t, addr,
non_constant_p, overflow_p);
break;
be NULL, meaning default-initialization, or it will be an lvalue
or xvalue of the same type, meaning direct-initialization from the
corresponding member. */
- r = cxx_eval_vec_init (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_vec_init (ctx, t, addr,
non_constant_p, overflow_p);
break;
case FMA_EXPR:
case VEC_PERM_EXPR:
- r = cxx_eval_trinary_expression (ctx, t, allow_non_constant, addr,
+ r = cxx_eval_trinary_expression (ctx, t, addr,
non_constant_p, overflow_p);
break;
{
tree oldop = TREE_OPERAND (t, 0);
tree op = cxx_eval_constant_expression (ctx, oldop,
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p,
NULL);
if (*non_constant_p)
&& TREE_CODE (op) == INTEGER_CST
&& !integer_zerop (op))
{
- if (!allow_non_constant)
+ if (!ctx->quiet)
error_at (EXPR_LOC_OR_LOC (t, input_location),
"reinterpret_cast from integer to pointer");
*non_constant_p = true;
case STATEMENT_LIST:
new_ctx = *ctx;
new_ctx.ctor = new_ctx.object = NULL_TREE;
- return cxx_eval_statement_list (&new_ctx, t, allow_non_constant,
+ return cxx_eval_statement_list (&new_ctx, t,
non_constant_p, overflow_p, jump_target);
case BIND_EXPR:
return cxx_eval_constant_expression (ctx, BIND_EXPR_BODY (t),
- allow_non_constant, addr,
+ addr,
non_constant_p, overflow_p,
jump_target);
case POSTINCREMENT_EXPR:
case PREDECREMENT_EXPR:
case POSTDECREMENT_EXPR:
- return cxx_eval_increment_expression (ctx, t, allow_non_constant,
+ return cxx_eval_increment_expression (ctx, t,
addr, non_constant_p, overflow_p);
case LAMBDA_EXPR:
case NON_DEPENDENT_EXPR:
case BASELINK:
case OFFSET_REF:
- if (!allow_non_constant)
+ if (!ctx->quiet)
error_at (EXPR_LOC_OR_LOC (t, input_location),
"expression %qE is not a constant-expression", t);
*non_constant_p = true;
/* A placeholder without a referent. We can get here when
checking whether NSDMIs are noexcept, or in massage_init_elt;
just say it's non-constant for now. */
- gcc_assert (allow_non_constant);
+ gcc_assert (ctx->quiet);
*non_constant_p = true;
break;
}
gcc_assert (same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (t), TREE_TYPE (ctor)));
return cxx_eval_constant_expression
- (ctx, ctor, allow_non_constant, addr,
+ (ctx, ctor, addr,
non_constant_p, overflow_p, NULL);
}
break;
break;
case LOOP_EXPR:
- cxx_eval_loop_expr (ctx, t, allow_non_constant,
+ cxx_eval_loop_expr (ctx, t,
non_constant_p, overflow_p, jump_target);
break;
case SWITCH_EXPR:
- cxx_eval_switch_expr (ctx, t, allow_non_constant,
+ cxx_eval_switch_expr (ctx, t,
non_constant_p, overflow_p, jump_target);
break;
{
bool non_constant_p = false;
bool overflow_p = false;
- constexpr_ctx ctx = { NULL, NULL, NULL, NULL };
+ constexpr_ctx ctx = { NULL, NULL, NULL, NULL, allow_non_constant };
hash_map<tree,tree> map;
ctx.values = ↦
tree type = initialized_type (t);
r = TARGET_EXPR_INITIAL (r);
}
- r = cxx_eval_constant_expression (&ctx, r, allow_non_constant,
+ r = cxx_eval_constant_expression (&ctx, r,
false, &non_constant_p, &overflow_p, NULL);
verify_constant (r, allow_non_constant, &non_constant_p, &overflow_p);
{
bool non_constant_p = false;
bool overflow_p = false;
- constexpr_ctx ctx = { NULL, NULL, NULL, NULL };
+ constexpr_ctx ctx = { NULL, NULL, NULL, NULL, true };
hash_map <tree, tree> map;
ctx.values = ↦
- cxx_eval_constant_expression (&ctx, t, true, false, &non_constant_p,
+ cxx_eval_constant_expression (&ctx, t, false, &non_constant_p,
&overflow_p, NULL);
return !non_constant_p && !overflow_p;
}