Commit 92a596e8 by Jason Merrill Committed by Jason Merrill

* constexpr.c: Change "addr" parm names to "lval".

From-SVN: r218831
parent 13f649f6
2014-12-17 Jason Merrill <jason@redhat.com> 2014-12-17 Jason Merrill <jason@redhat.com>
* constexpr.c: Change "addr" parm names to "lval".
* constexpr.c: Tweak comments and formatting. * constexpr.c: Tweak comments and formatting.
2014-12-16 Paolo Carlini <paolo.carlini@oracle.com> 2014-12-16 Paolo Carlini <paolo.carlini@oracle.com>
......
...@@ -999,7 +999,7 @@ lookup_parameter_binding (const constexpr_call *call, tree t) ...@@ -999,7 +999,7 @@ lookup_parameter_binding (const constexpr_call *call, tree t)
static tree static tree
cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
const int nargs = call_expr_nargs (t); const int nargs = call_expr_nargs (t);
...@@ -1009,7 +1009,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, ...@@ -1009,7 +1009,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t,
for (i = 0; i < nargs; ++i) for (i = 0; i < nargs; ++i)
{ {
args[i] = cxx_eval_constant_expression (ctx, CALL_EXPR_ARG (t, i), args[i] = cxx_eval_constant_expression (ctx, CALL_EXPR_ARG (t, i),
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
if (ctx->quiet && *non_constant_p) if (ctx->quiet && *non_constant_p)
return t; return t;
...@@ -1071,7 +1071,7 @@ cxx_bind_parameters_in_call (const constexpr_ctx *ctx, tree t, ...@@ -1071,7 +1071,7 @@ cxx_bind_parameters_in_call (const constexpr_ctx *ctx, tree t,
x = ctx->object; x = ctx->object;
x = cp_build_addr_expr (x, tf_warning_or_error); x = cp_build_addr_expr (x, tf_warning_or_error);
} }
bool addr = false; bool lval = false;
if (parms && DECL_BY_REFERENCE (parms) && !use_new_call) if (parms && DECL_BY_REFERENCE (parms) && !use_new_call)
{ {
/* cp_genericize made this a reference for argument passing, but /* cp_genericize made this a reference for argument passing, but
...@@ -1082,9 +1082,9 @@ cxx_bind_parameters_in_call (const constexpr_ctx *ctx, tree t, ...@@ -1082,9 +1082,9 @@ cxx_bind_parameters_in_call (const constexpr_ctx *ctx, tree t,
gcc_assert (TREE_CODE (TREE_TYPE (x)) == REFERENCE_TYPE); gcc_assert (TREE_CODE (TREE_TYPE (x)) == REFERENCE_TYPE);
type = TREE_TYPE (type); type = TREE_TYPE (type);
x = convert_from_reference (x); x = convert_from_reference (x);
addr = true; lval = true;
} }
arg = cxx_eval_constant_expression (ctx, x, addr, arg = cxx_eval_constant_expression (ctx, x, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
/* Don't VERIFY_CONSTANT here. */ /* Don't VERIFY_CONSTANT here. */
if (*non_constant_p && ctx->quiet) if (*non_constant_p && ctx->quiet)
...@@ -1150,7 +1150,7 @@ cx_error_context (void) ...@@ -1150,7 +1150,7 @@ cx_error_context (void)
static tree static tree
cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
location_t loc = EXPR_LOC_OR_LOC (t, input_location); location_t loc = EXPR_LOC_OR_LOC (t, input_location);
...@@ -1178,7 +1178,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, ...@@ -1178,7 +1178,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
{ {
/* Might be a constexpr function pointer. */ /* Might be a constexpr function pointer. */
fun = cxx_eval_constant_expression (ctx, fun, fun = cxx_eval_constant_expression (ctx, fun,
/*addr*/false, non_constant_p, /*lval*/false, non_constant_p,
overflow_p); overflow_p);
STRIP_NOPS (fun); STRIP_NOPS (fun);
if (TREE_CODE (fun) == ADDR_EXPR) if (TREE_CODE (fun) == ADDR_EXPR)
...@@ -1200,7 +1200,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, ...@@ -1200,7 +1200,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
if (is_builtin_fn (fun)) if (is_builtin_fn (fun))
return cxx_eval_builtin_function_call (ctx, t, return cxx_eval_builtin_function_call (ctx, t,
addr, non_constant_p, overflow_p); lval, non_constant_p, overflow_p);
if (!DECL_DECLARED_CONSTEXPR_P (fun)) if (!DECL_DECLARED_CONSTEXPR_P (fun))
{ {
if (!ctx->quiet) if (!ctx->quiet)
...@@ -1219,7 +1219,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, ...@@ -1219,7 +1219,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
{ {
tree arg = convert_from_reference (get_nth_callarg (t, 1)); tree arg = convert_from_reference (get_nth_callarg (t, 1));
return cxx_eval_constant_expression (ctx, arg, return cxx_eval_constant_expression (ctx, arg,
addr, non_constant_p, lval, non_constant_p,
overflow_p); overflow_p);
} }
else if (TREE_CODE (t) == AGGR_INIT_EXPR else if (TREE_CODE (t) == AGGR_INIT_EXPR
...@@ -1315,7 +1315,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, ...@@ -1315,7 +1315,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
new_ctx.call = &new_call; new_ctx.call = &new_call;
result = (cxx_eval_constant_expression result = (cxx_eval_constant_expression
(&new_ctx, new_call.fundef->body, (&new_ctx, new_call.fundef->body,
addr, lval,
non_constant_p, overflow_p)); non_constant_p, overflow_p));
} }
else else
...@@ -1358,7 +1358,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, ...@@ -1358,7 +1358,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
tree jump_target = NULL_TREE; tree jump_target = NULL_TREE;
cxx_eval_constant_expression (ctx, body, cxx_eval_constant_expression (ctx, body,
addr, non_constant_p, overflow_p, lval, non_constant_p, overflow_p,
&jump_target); &jump_target);
if (DECL_CONSTRUCTOR_P (fun)) if (DECL_CONSTRUCTOR_P (fun))
...@@ -1367,7 +1367,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, ...@@ -1367,7 +1367,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
side-effects rather than the value. We could get at the side-effects rather than the value. We could get at the
value by evaluating *this, but we don't bother; there's value by evaluating *this, but we don't bother; there's
no need to put such a call in the hash table. */ no need to put such a call in the hash table. */
result = addr ? ctx->object : ctx->ctor; result = lval ? ctx->object : ctx->ctor;
else else
{ {
result = *ctx->values->get (slot ? slot : res); result = *ctx->values->get (slot ? slot : res);
...@@ -1558,13 +1558,13 @@ cxx_eval_check_shift_p (location_t loc, const constexpr_ctx *ctx, ...@@ -1558,13 +1558,13 @@ cxx_eval_check_shift_p (location_t loc, const constexpr_ctx *ctx,
static tree static tree
cxx_eval_unary_expression (const constexpr_ctx *ctx, tree t, cxx_eval_unary_expression (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
tree r; tree r;
tree orig_arg = TREE_OPERAND (t, 0); tree orig_arg = TREE_OPERAND (t, 0);
tree arg = cxx_eval_constant_expression (ctx, orig_arg, tree arg = cxx_eval_constant_expression (ctx, orig_arg,
addr, non_constant_p, overflow_p); lval, non_constant_p, overflow_p);
VERIFY_CONSTANT (arg); VERIFY_CONSTANT (arg);
location_t loc = EXPR_LOCATION (t); location_t loc = EXPR_LOCATION (t);
enum tree_code code = TREE_CODE (t); enum tree_code code = TREE_CODE (t);
...@@ -1586,7 +1586,7 @@ cxx_eval_unary_expression (const constexpr_ctx *ctx, tree t, ...@@ -1586,7 +1586,7 @@ cxx_eval_unary_expression (const constexpr_ctx *ctx, tree t,
static tree static tree
cxx_eval_binary_expression (const constexpr_ctx *ctx, tree t, cxx_eval_binary_expression (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
tree r; tree r;
...@@ -1594,11 +1594,11 @@ cxx_eval_binary_expression (const constexpr_ctx *ctx, tree t, ...@@ -1594,11 +1594,11 @@ cxx_eval_binary_expression (const constexpr_ctx *ctx, tree t,
tree orig_rhs = TREE_OPERAND (t, 1); tree orig_rhs = TREE_OPERAND (t, 1);
tree lhs, rhs; tree lhs, rhs;
lhs = cxx_eval_constant_expression (ctx, orig_lhs, lhs = cxx_eval_constant_expression (ctx, orig_lhs,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
VERIFY_CONSTANT (lhs); VERIFY_CONSTANT (lhs);
rhs = cxx_eval_constant_expression (ctx, orig_rhs, rhs = cxx_eval_constant_expression (ctx, orig_rhs,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
VERIFY_CONSTANT (rhs); VERIFY_CONSTANT (rhs);
...@@ -1625,22 +1625,22 @@ cxx_eval_binary_expression (const constexpr_ctx *ctx, tree t, ...@@ -1625,22 +1625,22 @@ cxx_eval_binary_expression (const constexpr_ctx *ctx, tree t,
static tree static tree
cxx_eval_conditional_expression (const constexpr_ctx *ctx, tree t, cxx_eval_conditional_expression (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p, bool *non_constant_p, bool *overflow_p,
tree *jump_target) tree *jump_target)
{ {
tree val = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0), tree val = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
VERIFY_CONSTANT (val); VERIFY_CONSTANT (val);
/* Don't VERIFY_CONSTANT the other operands. */ /* Don't VERIFY_CONSTANT the other operands. */
if (integer_zerop (val)) if (integer_zerop (val))
return cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 2), return cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 2),
addr, lval,
non_constant_p, overflow_p, non_constant_p, overflow_p,
jump_target); jump_target);
return cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1), return cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
addr, lval,
non_constant_p, overflow_p, non_constant_p, overflow_p,
jump_target); jump_target);
} }
...@@ -1650,12 +1650,12 @@ cxx_eval_conditional_expression (const constexpr_ctx *ctx, tree t, ...@@ -1650,12 +1650,12 @@ cxx_eval_conditional_expression (const constexpr_ctx *ctx, tree t,
static tree static tree
cxx_eval_array_reference (const constexpr_ctx *ctx, tree t, cxx_eval_array_reference (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
tree oldary = TREE_OPERAND (t, 0); tree oldary = TREE_OPERAND (t, 0);
tree ary = cxx_eval_constant_expression (ctx, oldary, tree ary = cxx_eval_constant_expression (ctx, oldary,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
tree index, oldidx; tree index, oldidx;
HOST_WIDE_INT i; HOST_WIDE_INT i;
...@@ -1668,9 +1668,9 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, tree t, ...@@ -1668,9 +1668,9 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, tree t,
false, false,
non_constant_p, overflow_p); non_constant_p, overflow_p);
VERIFY_CONSTANT (index); VERIFY_CONSTANT (index);
if (addr && ary == oldary && index == oldidx) if (lval && ary == oldary && index == oldidx)
return t; return t;
else if (addr) else if (lval)
return build4 (ARRAY_REF, TREE_TYPE (t), ary, index, NULL, NULL); return build4 (ARRAY_REF, TREE_TYPE (t), ary, index, NULL, NULL);
elem_type = TREE_TYPE (TREE_TYPE (ary)); elem_type = TREE_TYPE (TREE_TYPE (ary));
if (TREE_CODE (ary) == CONSTRUCTOR) if (TREE_CODE (ary) == CONSTRUCTOR)
...@@ -1696,7 +1696,7 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, tree t, ...@@ -1696,7 +1696,7 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, tree t,
initializer, it's value-initialized. */ initializer, it's value-initialized. */
tree val = build_value_init (elem_type, tf_warning_or_error); tree val = build_value_init (elem_type, tf_warning_or_error);
return cxx_eval_constant_expression (ctx, val, return cxx_eval_constant_expression (ctx, val,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
} }
...@@ -1733,7 +1733,7 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, tree t, ...@@ -1733,7 +1733,7 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, tree t,
static tree static tree
cxx_eval_component_reference (const constexpr_ctx *ctx, tree t, cxx_eval_component_reference (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
unsigned HOST_WIDE_INT i; unsigned HOST_WIDE_INT i;
...@@ -1742,11 +1742,11 @@ cxx_eval_component_reference (const constexpr_ctx *ctx, tree t, ...@@ -1742,11 +1742,11 @@ cxx_eval_component_reference (const constexpr_ctx *ctx, tree t,
tree part = TREE_OPERAND (t, 1); tree part = TREE_OPERAND (t, 1);
tree orig_whole = TREE_OPERAND (t, 0); tree orig_whole = TREE_OPERAND (t, 0);
tree whole = cxx_eval_constant_expression (ctx, orig_whole, tree whole = cxx_eval_constant_expression (ctx, orig_whole,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
if (whole == orig_whole) if (whole == orig_whole)
return t; return t;
if (addr) if (lval)
return fold_build3 (COMPONENT_REF, TREE_TYPE (t), return fold_build3 (COMPONENT_REF, TREE_TYPE (t),
whole, part, NULL_TREE); whole, part, NULL_TREE);
/* Don't VERIFY_CONSTANT here; we only want to check that we got a /* Don't VERIFY_CONSTANT here; we only want to check that we got a
...@@ -1801,7 +1801,7 @@ cxx_eval_component_reference (const constexpr_ctx *ctx, tree t, ...@@ -1801,7 +1801,7 @@ cxx_eval_component_reference (const constexpr_ctx *ctx, tree t,
/* If there's no explicit init for this field, it's value-initialized. */ /* If there's no explicit init for this field, it's value-initialized. */
value = build_value_init (TREE_TYPE (t), tf_warning_or_error); value = build_value_init (TREE_TYPE (t), tf_warning_or_error);
return cxx_eval_constant_expression (ctx, value, return cxx_eval_constant_expression (ctx, value,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
} }
...@@ -1811,7 +1811,7 @@ cxx_eval_component_reference (const constexpr_ctx *ctx, tree t, ...@@ -1811,7 +1811,7 @@ cxx_eval_component_reference (const constexpr_ctx *ctx, tree t,
static tree static tree
cxx_eval_bit_field_ref (const constexpr_ctx *ctx, tree t, cxx_eval_bit_field_ref (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
tree orig_whole = TREE_OPERAND (t, 0); tree orig_whole = TREE_OPERAND (t, 0);
...@@ -1819,7 +1819,7 @@ cxx_eval_bit_field_ref (const constexpr_ctx *ctx, tree t, ...@@ -1819,7 +1819,7 @@ cxx_eval_bit_field_ref (const constexpr_ctx *ctx, tree t,
bool fld_seen = false; bool fld_seen = false;
HOST_WIDE_INT istart, isize; HOST_WIDE_INT istart, isize;
tree whole = cxx_eval_constant_expression (ctx, orig_whole, tree whole = cxx_eval_constant_expression (ctx, orig_whole,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
tree start, field, value; tree start, field, value;
unsigned HOST_WIDE_INT i; unsigned HOST_WIDE_INT i;
...@@ -1897,19 +1897,19 @@ cxx_eval_bit_field_ref (const constexpr_ctx *ctx, tree t, ...@@ -1897,19 +1897,19 @@ cxx_eval_bit_field_ref (const constexpr_ctx *ctx, tree t,
static tree static tree
cxx_eval_logical_expression (const constexpr_ctx *ctx, tree t, cxx_eval_logical_expression (const constexpr_ctx *ctx, tree t,
tree bailout_value, tree continue_value, tree bailout_value, tree continue_value,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
tree r; tree r;
tree lhs = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0), tree lhs = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
VERIFY_CONSTANT (lhs); VERIFY_CONSTANT (lhs);
if (tree_int_cst_equal (lhs, bailout_value)) if (tree_int_cst_equal (lhs, bailout_value))
return lhs; return lhs;
gcc_assert (tree_int_cst_equal (lhs, continue_value)); gcc_assert (tree_int_cst_equal (lhs, continue_value));
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1), r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
addr, non_constant_p, lval, non_constant_p,
overflow_p); overflow_p);
VERIFY_CONSTANT (r); VERIFY_CONSTANT (r);
return r; return r;
...@@ -2031,7 +2031,7 @@ verify_ctor_sanity (const constexpr_ctx *ctx, tree type) ...@@ -2031,7 +2031,7 @@ verify_ctor_sanity (const constexpr_ctx *ctx, tree type)
static tree static tree
cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t, cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (t); vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (t);
...@@ -2052,7 +2052,7 @@ cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t, ...@@ -2052,7 +2052,7 @@ cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t,
initializers can refer to it. */ initializers can refer to it. */
CONSTRUCTOR_APPEND_ELT (*p, index, new_ctx.ctor); CONSTRUCTOR_APPEND_ELT (*p, index, new_ctx.ctor);
tree elt = cxx_eval_constant_expression (&new_ctx, value, tree elt = cxx_eval_constant_expression (&new_ctx, value,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
/* Don't VERIFY_CONSTANT here. */ /* Don't VERIFY_CONSTANT here. */
if (ctx->quiet && *non_constant_p) if (ctx->quiet && *non_constant_p)
...@@ -2111,7 +2111,7 @@ cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t, ...@@ -2111,7 +2111,7 @@ cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t,
static tree static tree
cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init, cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
bool value_init, bool addr, bool value_init, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
tree elttype = TREE_TYPE (atype); tree elttype = TREE_TYPE (atype);
...@@ -2162,7 +2162,7 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init, ...@@ -2162,7 +2162,7 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
eltinit = cp_build_array_ref (input_location, init, idx, eltinit = cp_build_array_ref (input_location, init, idx,
tf_warning_or_error); tf_warning_or_error);
eltinit = cxx_eval_vec_init_1 (&new_ctx, elttype, eltinit, value_init, eltinit = cxx_eval_vec_init_1 (&new_ctx, elttype, eltinit, value_init,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
} }
else if (pre_init) else if (pre_init)
...@@ -2171,7 +2171,7 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init, ...@@ -2171,7 +2171,7 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
we just pre-built above. */ we just pre-built above. */
eltinit = (cxx_eval_constant_expression eltinit = (cxx_eval_constant_expression
(&new_ctx, init, (&new_ctx, init,
addr, non_constant_p, overflow_p)); lval, non_constant_p, overflow_p));
} }
else else
{ {
...@@ -2184,7 +2184,7 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init, ...@@ -2184,7 +2184,7 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
eltinit = move (eltinit); eltinit = move (eltinit);
eltinit = force_rvalue (eltinit, tf_warning_or_error); eltinit = force_rvalue (eltinit, tf_warning_or_error);
eltinit = (cxx_eval_constant_expression eltinit = (cxx_eval_constant_expression
(&new_ctx, eltinit, addr, (&new_ctx, eltinit, lval,
non_constant_p, overflow_p)); non_constant_p, overflow_p));
} }
if (*non_constant_p && !ctx->quiet) if (*non_constant_p && !ctx->quiet)
...@@ -2209,14 +2209,14 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init, ...@@ -2209,14 +2209,14 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
static tree static tree
cxx_eval_vec_init (const constexpr_ctx *ctx, tree t, cxx_eval_vec_init (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
tree atype = TREE_TYPE (t); tree atype = TREE_TYPE (t);
tree init = VEC_INIT_EXPR_INIT (t); tree init = VEC_INIT_EXPR_INIT (t);
tree r = cxx_eval_vec_init_1 (ctx, atype, init, tree r = cxx_eval_vec_init_1 (ctx, atype, init,
VEC_INIT_EXPR_VALUE_INIT (t), VEC_INIT_EXPR_VALUE_INIT (t),
addr, non_constant_p, overflow_p); lval, non_constant_p, overflow_p);
if (*non_constant_p) if (*non_constant_p)
return t; return t;
else else
...@@ -2416,12 +2416,12 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree op0, bool *empty_base) ...@@ -2416,12 +2416,12 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree op0, bool *empty_base)
static tree static tree
cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t, cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
tree orig_op0 = TREE_OPERAND (t, 0); tree orig_op0 = TREE_OPERAND (t, 0);
tree op0 = cxx_eval_constant_expression (ctx, orig_op0, tree op0 = cxx_eval_constant_expression (ctx, orig_op0,
/*addr*/false, non_constant_p, /*lval*/false, non_constant_p,
overflow_p); overflow_p);
bool empty_base = false; bool empty_base = false;
tree r; tree r;
...@@ -2435,7 +2435,7 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t, ...@@ -2435,7 +2435,7 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t,
if (r) if (r)
r = cxx_eval_constant_expression (ctx, r, r = cxx_eval_constant_expression (ctx, r,
addr, non_constant_p, overflow_p); lval, non_constant_p, overflow_p);
else else
{ {
tree sub = op0; tree sub = op0;
...@@ -2459,7 +2459,7 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t, ...@@ -2459,7 +2459,7 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t,
/* If we're pulling out the value of an empty base, make sure /* If we're pulling out the value of an empty base, make sure
that the whole object is constant and then return an empty that the whole object is constant and then return an empty
CONSTRUCTOR. */ CONSTRUCTOR. */
if (empty_base && !addr) if (empty_base && !lval)
{ {
VERIFY_CONSTANT (r); VERIFY_CONSTANT (r);
r = build_constructor (TREE_TYPE (t), NULL); r = build_constructor (TREE_TYPE (t), NULL);
...@@ -2468,9 +2468,9 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t, ...@@ -2468,9 +2468,9 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t,
if (r == NULL_TREE) if (r == NULL_TREE)
{ {
if (addr && op0 != orig_op0) if (lval && op0 != orig_op0)
return build1 (INDIRECT_REF, TREE_TYPE (t), op0); return build1 (INDIRECT_REF, TREE_TYPE (t), op0);
if (!addr) if (!lval)
VERIFY_CONSTANT (t); VERIFY_CONSTANT (t);
return t; return t;
} }
...@@ -2526,7 +2526,7 @@ non_const_var_error (tree r) ...@@ -2526,7 +2526,7 @@ non_const_var_error (tree r)
static tree static tree
cxx_eval_trinary_expression (const constexpr_ctx *ctx, tree t, cxx_eval_trinary_expression (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
int i; int i;
...@@ -2536,7 +2536,7 @@ cxx_eval_trinary_expression (const constexpr_ctx *ctx, tree t, ...@@ -2536,7 +2536,7 @@ cxx_eval_trinary_expression (const constexpr_ctx *ctx, tree t,
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
args[i] = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, i), args[i] = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, i),
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
VERIFY_CONSTANT (args[i]); VERIFY_CONSTANT (args[i]);
} }
...@@ -2561,7 +2561,7 @@ var_in_constexpr_fn (tree t) ...@@ -2561,7 +2561,7 @@ var_in_constexpr_fn (tree t)
static tree static tree
cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
constexpr_ctx new_ctx = *ctx; constexpr_ctx new_ctx = *ctx;
...@@ -2658,7 +2658,7 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, ...@@ -2658,7 +2658,7 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
if (*non_constant_p) if (*non_constant_p)
return t; return t;
else if (addr) else if (lval)
return target; return target;
else else
return init; return init;
...@@ -2668,7 +2668,7 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, ...@@ -2668,7 +2668,7 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
static tree static tree
cxx_eval_increment_expression (const constexpr_ctx *ctx, tree t, cxx_eval_increment_expression (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
enum tree_code code = TREE_CODE (t); enum tree_code code = TREE_CODE (t);
...@@ -2711,7 +2711,7 @@ cxx_eval_increment_expression (const constexpr_ctx *ctx, tree t, ...@@ -2711,7 +2711,7 @@ cxx_eval_increment_expression (const constexpr_ctx *ctx, tree t,
if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR) if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR)
{ {
/* Prefix ops are lvalues. */ /* Prefix ops are lvalues. */
if (addr) if (lval)
return op; return op;
else else
/* But we optimize when the caller wants an rvalue. */ /* But we optimize when the caller wants an rvalue. */
...@@ -2886,7 +2886,7 @@ cxx_eval_switch_expr (const constexpr_ctx *ctx, tree t, ...@@ -2886,7 +2886,7 @@ cxx_eval_switch_expr (const constexpr_ctx *ctx, tree t,
static tree static tree
cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
bool addr, bool lval,
bool *non_constant_p, bool *overflow_p, bool *non_constant_p, bool *overflow_p,
tree *jump_target) tree *jump_target)
{ {
...@@ -2913,7 +2913,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -2913,7 +2913,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
switch (TREE_CODE (t)) switch (TREE_CODE (t))
{ {
case RESULT_DECL: case RESULT_DECL:
if (addr) if (lval)
return t; return t;
/* We ask for an rvalue for the RESULT_DECL when indirecting /* We ask for an rvalue for the RESULT_DECL when indirecting
through an invisible reference. */ through an invisible reference. */
...@@ -2921,7 +2921,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -2921,7 +2921,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
return (*ctx->values->get (t)); return (*ctx->values->get (t));
case VAR_DECL: case VAR_DECL:
if (addr) if (lval)
return t; return t;
/* else fall through. */ /* else fall through. */
case CONST_DECL: case CONST_DECL:
...@@ -2954,11 +2954,11 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -2954,11 +2954,11 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
if (!use_new_call && ctx if (!use_new_call && ctx
&& ctx->call && DECL_CONTEXT (t) == ctx->call->fundef->decl) && ctx->call && DECL_CONTEXT (t) == ctx->call->fundef->decl)
r = lookup_parameter_binding (ctx->call, t); r = lookup_parameter_binding (ctx->call, t);
else if (addr && TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE) else if (lval && TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE)
/* glvalue use. */; /* glvalue use. */;
else if (tree *p = ctx->values->get (r)) else if (tree *p = ctx->values->get (r))
r = *p; r = *p;
else if (addr) else if (lval)
/* Defer in case this is only used for its type. */; /* Defer in case this is only used for its type. */;
else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE) else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
/* Defer, there's no lvalue->rvalue conversion. */; /* Defer, there's no lvalue->rvalue conversion. */;
...@@ -2978,7 +2978,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -2978,7 +2978,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case CALL_EXPR: case CALL_EXPR:
case AGGR_INIT_EXPR: case AGGR_INIT_EXPR:
r = cxx_eval_call_expression (ctx, t, addr, r = cxx_eval_call_expression (ctx, t, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
...@@ -3034,7 +3034,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3034,7 +3034,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
ctx->values->put (new_ctx.object, new_ctx.ctor); ctx->values->put (new_ctx.object, new_ctx.ctor);
ctx = &new_ctx; ctx = &new_ctx;
} }
/* Pass false for 'addr' because this indicates /* Pass false for 'lval' because this indicates
initialization of a temporary. */ initialization of a temporary. */
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1), r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
false, false,
...@@ -3042,7 +3042,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3042,7 +3042,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
if (!*non_constant_p) if (!*non_constant_p)
/* Adjust the type of the result to the type of the temporary. */ /* Adjust the type of the result to the type of the temporary. */
r = adjust_temp_type (TREE_TYPE (t), r); r = adjust_temp_type (TREE_TYPE (t), r);
if (addr) if (lval)
{ {
tree slot = TARGET_EXPR_SLOT (t); tree slot = TARGET_EXPR_SLOT (t);
ctx->values->put (slot, r); ctx->values->put (slot, r);
...@@ -3062,19 +3062,19 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3062,19 +3062,19 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
} }
/* else fall through */ /* else fall through */
case MODIFY_EXPR: case MODIFY_EXPR:
r = cxx_eval_store_expression (ctx, t, addr, r = cxx_eval_store_expression (ctx, t, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
case SCOPE_REF: case SCOPE_REF:
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1), r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
case RETURN_EXPR: case RETURN_EXPR:
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0), r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
*jump_target = t; *jump_target = t;
break; break;
...@@ -3098,7 +3098,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3098,7 +3098,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case EXPR_STMT: case EXPR_STMT:
case EH_SPEC_BLOCK: case EH_SPEC_BLOCK:
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0), r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
addr, lval,
non_constant_p, overflow_p, non_constant_p, overflow_p,
jump_target); jump_target);
break; break;
...@@ -3107,7 +3107,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3107,7 +3107,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
check for a constant operand or result; an address can be check for a constant operand or result; an address can be
constant without its operand being, and vice versa. */ constant without its operand being, and vice versa. */
case INDIRECT_REF: case INDIRECT_REF:
r = cxx_eval_indirect_ref (ctx, t, addr, r = cxx_eval_indirect_ref (ctx, t, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
...@@ -3115,7 +3115,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3115,7 +3115,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
{ {
tree oldop = TREE_OPERAND (t, 0); tree oldop = TREE_OPERAND (t, 0);
tree op = cxx_eval_constant_expression (ctx, oldop, tree op = cxx_eval_constant_expression (ctx, oldop,
/*addr*/true, /*lval*/true,
non_constant_p, overflow_p); non_constant_p, overflow_p);
/* Don't VERIFY_CONSTANT here. */ /* Don't VERIFY_CONSTANT here. */
if (*non_constant_p) if (*non_constant_p)
...@@ -3138,7 +3138,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3138,7 +3138,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case BIT_NOT_EXPR: case BIT_NOT_EXPR:
case TRUTH_NOT_EXPR: case TRUTH_NOT_EXPR:
case FIXED_CONVERT_EXPR: case FIXED_CONVERT_EXPR:
r = cxx_eval_unary_expression (ctx, t, addr, r = cxx_eval_unary_expression (ctx, t, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
...@@ -3168,7 +3168,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3168,7 +3168,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
if ((TREE_CODE (op0) == TARGET_EXPR && op1 == TARGET_EXPR_SLOT (op0)) if ((TREE_CODE (op0) == TARGET_EXPR && op1 == TARGET_EXPR_SLOT (op0))
|| TREE_CODE (op1) == EMPTY_CLASS_EXPR) || TREE_CODE (op1) == EMPTY_CLASS_EXPR)
r = cxx_eval_constant_expression (ctx, op0, r = cxx_eval_constant_expression (ctx, op0,
addr, non_constant_p, overflow_p, lval, non_constant_p, overflow_p,
jump_target); jump_target);
else else
{ {
...@@ -3178,7 +3178,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3178,7 +3178,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
jump_target); jump_target);
op1 = TREE_OPERAND (t, 1); op1 = TREE_OPERAND (t, 1);
r = cxx_eval_constant_expression (ctx, op1, r = cxx_eval_constant_expression (ctx, op1,
addr, non_constant_p, overflow_p, lval, non_constant_p, overflow_p,
jump_target); jump_target);
} }
} }
...@@ -3223,7 +3223,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3223,7 +3223,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case LTGT_EXPR: case LTGT_EXPR:
case RANGE_EXPR: case RANGE_EXPR:
case COMPLEX_EXPR: case COMPLEX_EXPR:
r = cxx_eval_binary_expression (ctx, t, addr, r = cxx_eval_binary_expression (ctx, t, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
...@@ -3233,7 +3233,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3233,7 +3233,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case TRUTH_ANDIF_EXPR: case TRUTH_ANDIF_EXPR:
r = cxx_eval_logical_expression (ctx, t, boolean_false_node, r = cxx_eval_logical_expression (ctx, t, boolean_false_node,
boolean_true_node, boolean_true_node,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
...@@ -3241,12 +3241,12 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3241,12 +3241,12 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case TRUTH_ORIF_EXPR: case TRUTH_ORIF_EXPR:
r = cxx_eval_logical_expression (ctx, t, boolean_true_node, r = cxx_eval_logical_expression (ctx, t, boolean_true_node,
boolean_false_node, boolean_false_node,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
case ARRAY_REF: case ARRAY_REF:
r = cxx_eval_array_reference (ctx, t, addr, r = cxx_eval_array_reference (ctx, t, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
...@@ -3261,24 +3261,24 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3261,24 +3261,24 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
*non_constant_p = true; *non_constant_p = true;
return t; return t;
} }
r = cxx_eval_component_reference (ctx, t, addr, r = cxx_eval_component_reference (ctx, t, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
case BIT_FIELD_REF: case BIT_FIELD_REF:
r = cxx_eval_bit_field_ref (ctx, t, addr, r = cxx_eval_bit_field_ref (ctx, t, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
case COND_EXPR: case COND_EXPR:
case VEC_COND_EXPR: case VEC_COND_EXPR:
r = cxx_eval_conditional_expression (ctx, t, addr, r = cxx_eval_conditional_expression (ctx, t, lval,
non_constant_p, overflow_p, non_constant_p, overflow_p,
jump_target); jump_target);
break; break;
case CONSTRUCTOR: case CONSTRUCTOR:
r = cxx_eval_bare_aggregate (ctx, t, addr, r = cxx_eval_bare_aggregate (ctx, t, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
...@@ -3288,13 +3288,13 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3288,13 +3288,13 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
be NULL, meaning default-initialization, or it will be an lvalue be NULL, meaning default-initialization, or it will be an lvalue
or xvalue of the same type, meaning direct-initialization from the or xvalue of the same type, meaning direct-initialization from the
corresponding member. */ corresponding member. */
r = cxx_eval_vec_init (ctx, t, addr, r = cxx_eval_vec_init (ctx, t, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
case FMA_EXPR: case FMA_EXPR:
case VEC_PERM_EXPR: case VEC_PERM_EXPR:
r = cxx_eval_trinary_expression (ctx, t, addr, r = cxx_eval_trinary_expression (ctx, t, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
...@@ -3304,7 +3304,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3304,7 +3304,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
{ {
tree oldop = TREE_OPERAND (t, 0); tree oldop = TREE_OPERAND (t, 0);
tree op = cxx_eval_constant_expression (ctx, oldop, tree op = cxx_eval_constant_expression (ctx, oldop,
addr, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
if (*non_constant_p) if (*non_constant_p)
return t; return t;
...@@ -3344,7 +3344,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3344,7 +3344,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case BIND_EXPR: case BIND_EXPR:
return cxx_eval_constant_expression (ctx, BIND_EXPR_BODY (t), return cxx_eval_constant_expression (ctx, BIND_EXPR_BODY (t),
addr, lval,
non_constant_p, overflow_p, non_constant_p, overflow_p,
jump_target); jump_target);
...@@ -3353,7 +3353,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3353,7 +3353,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case PREDECREMENT_EXPR: case PREDECREMENT_EXPR:
case POSTDECREMENT_EXPR: case POSTDECREMENT_EXPR:
return cxx_eval_increment_expression (ctx, t, return cxx_eval_increment_expression (ctx, t,
addr, non_constant_p, overflow_p); lval, non_constant_p, overflow_p);
case LAMBDA_EXPR: case LAMBDA_EXPR:
case NEW_EXPR: case NEW_EXPR:
...@@ -3376,7 +3376,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3376,7 +3376,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
break; break;
case PLACEHOLDER_EXPR: case PLACEHOLDER_EXPR:
if (!ctx || !ctx->ctor || (addr && !ctx->object)) if (!ctx || !ctx->ctor || (lval && !ctx->object))
{ {
/* A placeholder without a referent. We can get here when /* A placeholder without a referent. We can get here when
checking whether NSDMIs are noexcept, or in massage_init_elt; checking whether NSDMIs are noexcept, or in massage_init_elt;
...@@ -3390,11 +3390,11 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3390,11 +3390,11 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
/* Use of the value or address of the current object. We could /* Use of the value or address of the current object. We could
use ctx->object unconditionally, but using ctx->ctor when we use ctx->object unconditionally, but using ctx->ctor when we
can is a minor optimization. */ can is a minor optimization. */
tree ctor = addr ? ctx->object : ctx->ctor; tree ctor = lval ? ctx->object : ctx->ctor;
gcc_assert (same_type_ignoring_top_level_qualifiers_p gcc_assert (same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (t), TREE_TYPE (ctor))); (TREE_TYPE (t), TREE_TYPE (ctor)));
return cxx_eval_constant_expression return cxx_eval_constant_expression
(ctx, ctor, addr, (ctx, ctor, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment