* cp-tree.h: Unpoison lvalue_p.
* call.c, class.c, constexpr.c, cvt.c, init.c, lambda.c, pt.c,
tree.c, typeck.c, typeck2.c: Use lvalue_p instead of
real_lvalue_p.
From-SVN: r238183
2016-07-08 Jason Merrill <jason@redhat.com>
+ * cp-tree.h: Unpoison lvalue_p.
+ * call.c, class.c, constexpr.c, cvt.c, init.c, lambda.c, pt.c,
+ tree.c, typeck.c, typeck2.c: Use lvalue_p instead of
+ real_lvalue_p.
+
* tree.c (obvalue_p): Rename from lvalue_p.
(lvalue_p): Define for c-common.
* call.c, cp-tree.h, cvt.c, init.c: Adjust.
if (code == COND_EXPR)
{
- if (real_lvalue_p (args[i]))
+ if (lvalue_p (args[i]))
vec_safe_push (types[i], build_reference_type (argtypes[i]));
vec_safe_push (types[i], TYPE_MAIN_VARIANT (argtypes[i]));
}
else
{
- if (code == COND_EXPR && real_lvalue_p (args[i]))
+ if (code == COND_EXPR && lvalue_p (args[i]))
vec_safe_push (types[i], build_reference_type (argtypes[i]));
type = non_reference (argtypes[i]);
if (i != 0 || ! ref1)
the constraint that the reference must bind directly. */
if (glvalue_p (e2))
{
- tree rtype = cp_build_reference_type (t2, !real_lvalue_p (e2));
+ tree rtype = cp_build_reference_type (t2, !lvalue_p (e2));
conv = implicit_conversion (rtype,
t1,
e1,
tree arg3_type;
tree result = NULL_TREE;
tree result_type = NULL_TREE;
- bool lvalue_p = true;
+ bool is_lvalue = true;
struct z_candidate *candidates = 0;
struct z_candidate *cand;
void *p;
"ISO C++ forbids omitting the middle term of a ?: expression");
/* Make sure that lvalues remain lvalues. See g++.oliva/ext1.C. */
- if (real_lvalue_p (arg1))
+ if (lvalue_p (arg1))
arg2 = arg1 = cp_stabilize_reference (arg1);
else
arg2 = arg1 = save_expr (arg1);
return error_mark_node;
}
- lvalue_p = false;
+ is_lvalue = false;
goto valid_operands;
}
/* [expr.cond]
|| (same_type_ignoring_top_level_qualifiers_p (arg2_type,
arg3_type)
&& glvalue_p (arg2) && glvalue_p (arg3)
- && real_lvalue_p (arg2) == real_lvalue_p (arg3))))
+ && lvalue_p (arg2) == lvalue_p (arg3))))
{
conversion *conv2;
conversion *conv3;
If the second and third operands are glvalues of the same value
category and have the same type, the result is of that type and
value category. */
- if (((real_lvalue_p (arg2) && real_lvalue_p (arg3))
+ if (((lvalue_p (arg2) && lvalue_p (arg3))
|| (xvalue_p (arg2) && xvalue_p (arg3)))
&& same_type_p (arg2_type, arg3_type))
{
cv-qualified) class type, overload resolution is used to
determine the conversions (if any) to be applied to the operands
(_over.match.oper_, _over.built_). */
- lvalue_p = false;
+ is_lvalue = false;
if (!same_type_p (arg2_type, arg3_type)
&& (CLASS_TYPE_P (arg2_type) || CLASS_TYPE_P (arg3_type)))
{
/* We can't use result_type below, as fold might have returned a
throw_expr. */
- if (!lvalue_p)
+ if (!is_lvalue)
{
/* Expand both sides into the same slot, hopefully the target of
the ?: expression. We used to check for TARGET_EXPRs here,
{
tree extype = TREE_TYPE (expr);
if (TYPE_REF_IS_RVALUE (ref_type)
- && real_lvalue_p (expr))
+ && lvalue_p (expr))
error_at (loc, "cannot bind %qT lvalue to %qT",
extype, totype);
- else if (!TYPE_REF_IS_RVALUE (ref_type) && !real_lvalue_p (expr)
+ else if (!TYPE_REF_IS_RVALUE (ref_type) && !lvalue_p (expr)
&& !CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (ref_type)))
error_at (loc, "invalid initialization of non-const reference of "
"type %qT from an rvalue of type %qT", totype, extype);
convert_like (conv, expr, complain);
else if (!CP_TYPE_CONST_P (TREE_TYPE (type))
&& !TYPE_REF_IS_RVALUE (type)
- && !real_lvalue_p (expr))
+ && !lvalue_p (expr))
error_at (loc, "invalid initialization of non-const reference of "
"type %qT from an rvalue of type %qT",
type, TREE_TYPE (expr));
if (!want_pointer)
{
- rvalue = !real_lvalue_p (expr);
+ rvalue = !lvalue_p (expr);
/* This must happen before the call to save_expr. */
expr = cp_build_addr_expr (expr, complain);
}
(atype, TREE_TYPE (init)));
eltinit = cp_build_array_ref (input_location, init, idx,
tf_warning_or_error);
- if (!real_lvalue_p (init))
+ if (!lvalue_p (init))
eltinit = move (eltinit);
eltinit = force_rvalue (eltinit, tf_warning_or_error);
eltinit = (cxx_eval_constant_expression
extern cp_lvalue_kind real_lvalue_p (const_tree);
extern cp_lvalue_kind lvalue_kind (const_tree);
extern bool glvalue_p (const_tree);
-/* obvalue_p used to be named lvalue_p, but that didn't match the C++
- definition of lvalue. For now, let's not use the name lvalue_p in the front
- end; later we can rename real_lvalue_p to lvalue_p. */
-#define lvalue_p(T) syntax error, use real_lvalue_p
extern bool obvalue_p (const_tree);
extern bool xvalue_p (const_tree);
extern tree cp_stabilize_reference (tree);
gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);
- if ((flags & DIRECT_BIND) && ! real_lvalue_p (arg))
+ if ((flags & DIRECT_BIND) && ! lvalue_p (arg))
{
/* Create a new temporary variable. We can't just use a TARGET_EXPR
here because it needs to live as long as DECL. */
= build_type_conversion (reftype, expr);
if (rval_as_conversion && rval_as_conversion != error_mark_node
- && real_lvalue_p (rval_as_conversion))
+ && lvalue_p (rval_as_conversion))
{
expr = rval_as_conversion;
rval_as_conversion = NULL_TREE;
tree ttr = lvalue_type (expr);
if ((complain & tf_error)
- && ! real_lvalue_p (expr))
+ && ! lvalue_p (expr))
diagnose_ref_binding (loc, reftype, intype, decl);
if (! (convtype & CONV_CONST)
vec_copy_assign_is_trivial (tree inner_elt_type, tree init)
{
tree fromtype = inner_elt_type;
- if (real_lvalue_p (init))
+ if (lvalue_p (init))
fromtype = cp_build_reference_type (fromtype, /*rval*/false);
return is_trivially_xible (MODIFY_EXPR, inner_elt_type, fromtype);
}
if (by_reference_p)
{
type = build_reference_type (type);
- if (!dependent_type_p (type) && !real_lvalue_p (initializer))
+ if (!dependent_type_p (type) && !lvalue_p (initializer))
error ("cannot capture %qE by reference", initializer);
}
else
return NULL_TREE;
}
- if (!real_lvalue_p (expr))
+ if (!lvalue_p (expr))
{
if (complain & tf_error)
error ("%qE is not a valid template argument for type %qT "
&& TYPE_REF_IS_RVALUE (*parm)
&& TREE_CODE (TREE_TYPE (*parm)) == TEMPLATE_TYPE_PARM
&& cp_type_quals (TREE_TYPE (*parm)) == TYPE_UNQUALIFIED
- && (arg_expr ? real_lvalue_p (arg_expr)
+ && (arg_expr ? lvalue_p (arg_expr)
/* try_one_overload doesn't provide an arg_expr, but
functions are always lvalues. */
: TREE_CODE (*arg) == FUNCTION_TYPE))
return op1_lvalue_kind;
}
-/* Returns the kind of lvalue that REF is, in the sense of
- [basic.lval]. This function should really be named lvalue_p; it
- computes the C++ definition of lvalue. */
+/* Returns the kind of lvalue that REF is, in the sense of [basic.lval]. */
cp_lvalue_kind
real_lvalue_p (const_tree ref)
return kind;
}
-/* Defined for c-common; the front end should use real_lvalue_p. */
+/* c-common wants us to return bool. */
bool
-(lvalue_p) (const_tree t)
+lvalue_p (const_tree t)
{
return real_lvalue_p (t);
}
-/* This differs from real_lvalue_p in that xvalues are included. */
+/* This differs from lvalue_p in that xvalues are included. */
bool
glvalue_p (const_tree ref)
{
tree init_type = strip_array_types (TREE_TYPE (init));
tree dummy = build_dummy_object (init_type);
- if (!real_lvalue_p (init))
+ if (!lvalue_p (init))
dummy = move (dummy);
argvec->quick_push (dummy);
}
;
else if (TREE_CODE (type) == ERROR_MARK)
;
- else if (real_lvalue_p (arg))
+ else if (lvalue_p (arg))
type = build_reference_type (lvalue_type (arg));
else if (MAYBE_CLASS_TYPE_P (type))
type = lvalue_type (arg);
}
else
{
- bool xval = !real_lvalue_p (exp);
+ bool xval = !lvalue_p (exp);
exp = cp_build_addr_expr (exp, tf_warning_or_error);
init_expr = get_target_expr (exp);
exp = TARGET_EXPR_SLOT (init_expr);
/* Remember that the result is an lvalue or xvalue. */
if (glvalue_p (expr) && !glvalue_p (min))
TREE_TYPE (min) = cp_build_reference_type (TREE_TYPE (min),
- !real_lvalue_p (expr));
+ !lvalue_p (expr));
expr = convert_from_reference (min);
}
return expr;
{
if ((TREE_CODE (type) == REFERENCE_TYPE
&& (TYPE_REF_IS_RVALUE (type)
- ? xvalue_p (expr) : real_lvalue_p (expr))
+ ? xvalue_p (expr) : lvalue_p (expr))
&& same_type_p (TREE_TYPE (expr), TREE_TYPE (type)))
|| same_type_p (TREE_TYPE (expr), type))
warning (OPT_Wuseless_cast, "useless cast to type %qT", type);
if (TREE_CODE (type) == REFERENCE_TYPE
&& CLASS_TYPE_P (TREE_TYPE (type))
&& CLASS_TYPE_P (intype)
- && (TYPE_REF_IS_RVALUE (type) || real_lvalue_p (expr))
+ && (TYPE_REF_IS_RVALUE (type) || lvalue_p (expr))
&& DERIVED_FROM_P (intype, TREE_TYPE (type))
&& can_convert (build_pointer_type (TYPE_MAIN_VARIANT (intype)),
build_pointer_type (TYPE_MAIN_VARIANT
reinterpret_cast. */
if (TREE_CODE (type) == REFERENCE_TYPE)
{
- if (! real_lvalue_p (expr))
+ if (! lvalue_p (expr))
{
if (complain & tf_error)
error ("invalid cast of an rvalue expression of type "
{
reference_type = dst_type;
if (!TYPE_REF_IS_RVALUE (dst_type)
- ? real_lvalue_p (expr)
+ ? lvalue_p (expr)
: obvalue_p (expr))
/* OK. */;
else
operand is a pointer to member function with ref-qualifier &&. */
if (FUNCTION_REF_QUALIFIED (type))
{
- bool lval = real_lvalue_p (datum);
+ bool lval = lvalue_p (datum);
if (lval && FUNCTION_RVALUE_QUALIFIED (type))
{
if (complain & tf_error)