static tree
cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
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),
- addr,
+ lval,
non_constant_p, overflow_p);
if (ctx->quiet && *non_constant_p)
return t;
x = ctx->object;
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)
{
/* cp_genericize made this a reference for argument passing, but
gcc_assert (TREE_CODE (TREE_TYPE (x)) == REFERENCE_TYPE);
type = TREE_TYPE (type);
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);
/* Don't VERIFY_CONSTANT here. */
if (*non_constant_p && ctx->quiet)
static tree
cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
bool *non_constant_p, bool *overflow_p)
{
location_t loc = EXPR_LOC_OR_LOC (t, input_location);
{
/* Might be a constexpr function pointer. */
fun = cxx_eval_constant_expression (ctx, fun,
- /*addr*/false, non_constant_p,
+ /*lval*/false, non_constant_p,
overflow_p);
STRIP_NOPS (fun);
if (TREE_CODE (fun) == ADDR_EXPR)
if (is_builtin_fn (fun))
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 (!ctx->quiet)
{
tree arg = convert_from_reference (get_nth_callarg (t, 1));
return cxx_eval_constant_expression (ctx, arg,
- addr, non_constant_p,
+ lval, non_constant_p,
overflow_p);
}
else if (TREE_CODE (t) == AGGR_INIT_EXPR
new_ctx.call = &new_call;
result = (cxx_eval_constant_expression
(&new_ctx, new_call.fundef->body,
- addr,
+ lval,
non_constant_p, overflow_p));
}
else
tree jump_target = NULL_TREE;
cxx_eval_constant_expression (ctx, body,
- addr, non_constant_p, overflow_p,
+ lval, non_constant_p, overflow_p,
&jump_target);
if (DECL_CONSTRUCTOR_P (fun))
side-effects rather than the value. We could get at the
value by evaluating *this, but we don't bother; there's
no need to put such a call in the hash table. */
- result = addr ? ctx->object : ctx->ctor;
+ result = lval ? ctx->object : ctx->ctor;
else
{
result = *ctx->values->get (slot ? slot : res);
static tree
cxx_eval_unary_expression (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
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,
- addr, non_constant_p, overflow_p);
+ lval, non_constant_p, overflow_p);
VERIFY_CONSTANT (arg);
location_t loc = EXPR_LOCATION (t);
enum tree_code code = TREE_CODE (t);
static tree
cxx_eval_binary_expression (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
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,
- addr,
+ lval,
non_constant_p, overflow_p);
VERIFY_CONSTANT (lhs);
rhs = cxx_eval_constant_expression (ctx, orig_rhs,
- addr,
+ lval,
non_constant_p, overflow_p);
VERIFY_CONSTANT (rhs);
static tree
cxx_eval_conditional_expression (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
bool *non_constant_p, bool *overflow_p,
tree *jump_target)
{
tree val = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
- addr,
+ lval,
non_constant_p, overflow_p);
VERIFY_CONSTANT (val);
/* Don't VERIFY_CONSTANT the other operands. */
if (integer_zerop (val))
return cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 2),
- addr,
+ lval,
non_constant_p, overflow_p,
jump_target);
return cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
- addr,
+ lval,
non_constant_p, overflow_p,
jump_target);
}
static tree
cxx_eval_array_reference (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
bool *non_constant_p, bool *overflow_p)
{
tree oldary = TREE_OPERAND (t, 0);
tree ary = cxx_eval_constant_expression (ctx, oldary,
- addr,
+ lval,
non_constant_p, overflow_p);
tree index, oldidx;
HOST_WIDE_INT i;
false,
non_constant_p, overflow_p);
VERIFY_CONSTANT (index);
- if (addr && ary == oldary && index == oldidx)
+ if (lval && ary == oldary && index == oldidx)
return t;
- else if (addr)
+ else if (lval)
return build4 (ARRAY_REF, TREE_TYPE (t), ary, index, NULL, NULL);
elem_type = TREE_TYPE (TREE_TYPE (ary));
if (TREE_CODE (ary) == CONSTRUCTOR)
initializer, it's value-initialized. */
tree val = build_value_init (elem_type, tf_warning_or_error);
return cxx_eval_constant_expression (ctx, val,
- addr,
+ lval,
non_constant_p, overflow_p);
}
static tree
cxx_eval_component_reference (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
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,
- addr,
+ lval,
non_constant_p, overflow_p);
if (whole == orig_whole)
return t;
- if (addr)
+ if (lval)
return fold_build3 (COMPONENT_REF, TREE_TYPE (t),
whole, part, NULL_TREE);
/* Don't VERIFY_CONSTANT here; we only want to check that we got a
/* 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,
- addr,
+ lval,
non_constant_p, overflow_p);
}
static tree
cxx_eval_bit_field_ref (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
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,
- addr,
+ lval,
non_constant_p, overflow_p);
tree start, field, value;
unsigned HOST_WIDE_INT i;
static tree
cxx_eval_logical_expression (const constexpr_ctx *ctx, tree t,
tree bailout_value, tree continue_value,
- bool addr,
+ bool lval,
bool *non_constant_p, bool *overflow_p)
{
tree r;
tree lhs = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
- addr,
+ lval,
non_constant_p, overflow_p);
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),
- addr, non_constant_p,
+ lval, non_constant_p,
overflow_p);
VERIFY_CONSTANT (r);
return r;
static tree
cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
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,
- addr,
+ lval,
non_constant_p, overflow_p);
/* Don't VERIFY_CONSTANT here. */
if (ctx->quiet && *non_constant_p)
static tree
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)
{
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,
- addr,
+ lval,
non_constant_p, overflow_p);
}
else if (pre_init)
we just pre-built above. */
eltinit = (cxx_eval_constant_expression
(&new_ctx, init,
- addr, non_constant_p, overflow_p));
+ lval, non_constant_p, overflow_p));
}
else
{
eltinit = move (eltinit);
eltinit = force_rvalue (eltinit, tf_warning_or_error);
eltinit = (cxx_eval_constant_expression
- (&new_ctx, eltinit, addr,
+ (&new_ctx, eltinit, lval,
non_constant_p, overflow_p));
}
if (*non_constant_p && !ctx->quiet)
static tree
cxx_eval_vec_init (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
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),
- addr, non_constant_p, overflow_p);
+ lval, 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 addr,
+ bool lval,
bool *non_constant_p, bool *overflow_p)
{
tree orig_op0 = TREE_OPERAND (t, 0);
tree op0 = cxx_eval_constant_expression (ctx, orig_op0,
- /*addr*/false, non_constant_p,
+ /*lval*/false, non_constant_p,
overflow_p);
bool empty_base = false;
tree r;
if (r)
r = cxx_eval_constant_expression (ctx, r,
- addr, non_constant_p, overflow_p);
+ lval, non_constant_p, overflow_p);
else
{
tree sub = op0;
/* If we're pulling out the value of an empty base, make sure
that the whole object is constant and then return an empty
CONSTRUCTOR. */
- if (empty_base && !addr)
+ if (empty_base && !lval)
{
VERIFY_CONSTANT (r);
r = build_constructor (TREE_TYPE (t), NULL);
if (r == NULL_TREE)
{
- if (addr && op0 != orig_op0)
+ if (lval && op0 != orig_op0)
return build1 (INDIRECT_REF, TREE_TYPE (t), op0);
- if (!addr)
+ if (!lval)
VERIFY_CONSTANT (t);
return t;
}
static tree
cxx_eval_trinary_expression (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
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),
- addr,
+ lval,
non_constant_p, overflow_p);
VERIFY_CONSTANT (args[i]);
}
static tree
cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
bool *non_constant_p, bool *overflow_p)
{
constexpr_ctx new_ctx = *ctx;
if (*non_constant_p)
return t;
- else if (addr)
+ else if (lval)
return target;
else
return init;
static tree
cxx_eval_increment_expression (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
bool *non_constant_p, bool *overflow_p)
{
enum tree_code code = TREE_CODE (t);
if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR)
{
/* Prefix ops are lvalues. */
- if (addr)
+ if (lval)
return op;
else
/* But we optimize when the caller wants an rvalue. */
static tree
cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
- bool addr,
+ bool lval,
bool *non_constant_p, bool *overflow_p,
tree *jump_target)
{
switch (TREE_CODE (t))
{
case RESULT_DECL:
- if (addr)
+ if (lval)
return t;
/* We ask for an rvalue for the RESULT_DECL when indirecting
through an invisible reference. */
return (*ctx->values->get (t));
case VAR_DECL:
- if (addr)
+ if (lval)
return t;
/* else fall through. */
case CONST_DECL:
if (!use_new_call && ctx
&& ctx->call && DECL_CONTEXT (t) == ctx->call->fundef->decl)
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. */;
else if (tree *p = ctx->values->get (r))
r = *p;
- else if (addr)
+ else if (lval)
/* Defer in case this is only used for its type. */;
else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
/* Defer, there's no lvalue->rvalue conversion. */;
case CALL_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);
break;
ctx->values->put (new_ctx.object, new_ctx.ctor);
ctx = &new_ctx;
}
- /* Pass false for 'addr' because this indicates
+ /* Pass false for 'lval' because this indicates
initialization of a temporary. */
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
false,
if (!*non_constant_p)
/* Adjust the type of the result to the type of the temporary. */
r = adjust_temp_type (TREE_TYPE (t), r);
- if (addr)
+ if (lval)
{
tree slot = TARGET_EXPR_SLOT (t);
ctx->values->put (slot, r);
}
/* else fall through */
case MODIFY_EXPR:
- r = cxx_eval_store_expression (ctx, t, addr,
+ r = cxx_eval_store_expression (ctx, t, lval,
non_constant_p, overflow_p);
break;
case SCOPE_REF:
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
- addr,
+ lval,
non_constant_p, overflow_p);
break;
case RETURN_EXPR:
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
- addr,
+ lval,
non_constant_p, overflow_p);
*jump_target = t;
break;
case EXPR_STMT:
case EH_SPEC_BLOCK:
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
- addr,
+ lval,
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, addr,
+ r = cxx_eval_indirect_ref (ctx, t, lval,
non_constant_p, overflow_p);
break;
{
tree oldop = TREE_OPERAND (t, 0);
tree op = cxx_eval_constant_expression (ctx, oldop,
- /*addr*/true,
+ /*lval*/true,
non_constant_p, overflow_p);
/* Don't VERIFY_CONSTANT here. */
if (*non_constant_p)
case BIT_NOT_EXPR:
case TRUTH_NOT_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);
break;
if ((TREE_CODE (op0) == TARGET_EXPR && op1 == TARGET_EXPR_SLOT (op0))
|| TREE_CODE (op1) == EMPTY_CLASS_EXPR)
r = cxx_eval_constant_expression (ctx, op0,
- addr, non_constant_p, overflow_p,
+ lval, non_constant_p, overflow_p,
jump_target);
else
{
jump_target);
op1 = TREE_OPERAND (t, 1);
r = cxx_eval_constant_expression (ctx, op1,
- addr, non_constant_p, overflow_p,
+ lval, non_constant_p, overflow_p,
jump_target);
}
}
case LTGT_EXPR:
case RANGE_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);
break;
case TRUTH_ANDIF_EXPR:
r = cxx_eval_logical_expression (ctx, t, boolean_false_node,
boolean_true_node,
- addr,
+ lval,
non_constant_p, overflow_p);
break;
case TRUTH_ORIF_EXPR:
r = cxx_eval_logical_expression (ctx, t, boolean_true_node,
boolean_false_node,
- addr,
+ lval,
non_constant_p, overflow_p);
break;
case ARRAY_REF:
- r = cxx_eval_array_reference (ctx, t, addr,
+ r = cxx_eval_array_reference (ctx, t, lval,
non_constant_p, overflow_p);
break;
*non_constant_p = true;
return t;
}
- r = cxx_eval_component_reference (ctx, t, addr,
+ r = cxx_eval_component_reference (ctx, t, lval,
non_constant_p, overflow_p);
break;
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);
break;
case 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,
jump_target);
break;
case CONSTRUCTOR:
- r = cxx_eval_bare_aggregate (ctx, t, addr,
+ r = cxx_eval_bare_aggregate (ctx, t, lval,
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, addr,
+ r = cxx_eval_vec_init (ctx, t, lval,
non_constant_p, overflow_p);
break;
case FMA_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);
break;
{
tree oldop = TREE_OPERAND (t, 0);
tree op = cxx_eval_constant_expression (ctx, oldop,
- addr,
+ lval,
non_constant_p, overflow_p);
if (*non_constant_p)
return t;
case BIND_EXPR:
return cxx_eval_constant_expression (ctx, BIND_EXPR_BODY (t),
- addr,
+ lval,
non_constant_p, overflow_p,
jump_target);
case PREDECREMENT_EXPR:
case POSTDECREMENT_EXPR:
return cxx_eval_increment_expression (ctx, t,
- addr, non_constant_p, overflow_p);
+ lval, non_constant_p, overflow_p);
case LAMBDA_EXPR:
case NEW_EXPR:
break;
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
checking whether NSDMIs are noexcept, or in massage_init_elt;
/* Use of the value or address of the current object. We could
use ctx->object unconditionally, but using ctx->ctor when we
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
(TREE_TYPE (t), TREE_TYPE (ctor)));
return cxx_eval_constant_expression
- (ctx, ctor, addr,
+ (ctx, ctor, lval,
non_constant_p, overflow_p);
}
break;