Rename lvalue_p to obvalue_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.
	* typeck.c: Adjust.
	(cp_build_addr_expr_1): Remove obsolete code.

From-SVN: r238182
This commit is contained in:
Jason Merrill 2016-07-08 17:32:12 -04:00 committed by Jason Merrill
parent c3edc63382
commit bb19d4af73
7 changed files with 31 additions and 19 deletions

View File

@ -1,5 +1,11 @@
2016-07-08 Jason Merrill <jason@redhat.com>
* tree.c (obvalue_p): Rename from lvalue_p.
(lvalue_p): Define for c-common.
* call.c, cp-tree.h, cvt.c, init.c: Adjust.
* typeck.c: Adjust.
(cp_build_addr_expr_1): Remove obsolete code.
* tree.c (glvalue_p): Rename from lvalue_or_rvalue_with_address_p.
* call.c, cp-tree.h, typeck.c: Adjust.

View File

@ -1126,7 +1126,10 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
fcode = TREE_CODE (from);
conv = build_conv (ck_lvalue, from, conv);
}
else if (fromref || (expr && lvalue_p (expr)))
/* Wrapping a ck_rvalue around a class prvalue (as a result of using
obvalue_p) seems odd, since it's already a prvalue, but that's how we
express the copy constructor call required by copy-initialization. */
else if (fromref || (expr && obvalue_p (expr)))
{
if (expr)
{

View File

@ -6516,6 +6516,11 @@ extern int member_p (const_tree);
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);
extern bool builtin_valid_in_constant_expr_p (const_tree);

View File

@ -330,7 +330,7 @@ build_up_reference (tree type, tree arg, int flags, tree decl,
cp_finish_decl (arg, targ, /*init_const_expr_p=*/false, NULL_TREE,
LOOKUP_ONLYCONVERTING|DIRECT_BIND);
}
else if (!(flags & DIRECT_BIND) && ! lvalue_p (arg))
else if (!(flags & DIRECT_BIND) && ! obvalue_p (arg))
return get_target_expr_sfinae (arg, complain);
/* If we had a way to wrap this up, and say, if we ever needed its
@ -473,7 +473,7 @@ convert_to_reference (tree reftype, tree expr, int convtype,
return build_up_reference (reftype, expr, flags, decl, complain);
}
else if ((convtype & CONV_REINTERPRET) && lvalue_p (expr))
else if ((convtype & CONV_REINTERPRET) && obvalue_p (expr))
{
/* When casting an lvalue to a reference type, just convert into
a pointer to the new type and deference it. This is allowed

View File

@ -3332,7 +3332,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
rval = build2 (COMPOUND_EXPR, TREE_TYPE (rval), init_preeval_expr, rval);
/* A new-expression is never an lvalue. */
gcc_assert (!lvalue_p (rval));
gcc_assert (!obvalue_p (rval));
return convert (pointer_type, rval);
}

View File

@ -266,6 +266,14 @@ real_lvalue_p (const_tree ref)
return kind;
}
/* Defined for c-common; the front end should use real_lvalue_p. */
bool
(lvalue_p) (const_tree t)
{
return real_lvalue_p (t);
}
/* This differs from real_lvalue_p in that xvalues are included. */
bool
@ -281,7 +289,7 @@ glvalue_p (const_tree ref)
/* This differs from glvalue_p in that class prvalues are included. */
bool
lvalue_p (const_tree ref)
obvalue_p (const_tree ref)
{
return (lvalue_kind (ref) != clk_none);
}

View File

@ -1987,7 +1987,7 @@ decay_conversion (tree exp,
TREE_OPERAND (exp, 0), op1);
}
if (!lvalue_p (exp)
if (!obvalue_p (exp)
&& ! (TREE_CODE (exp) == CONSTRUCTOR && TREE_STATIC (exp)))
{
if (complain & tf_error)
@ -5678,16 +5678,8 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
CASE_CONVERT:
case FLOAT_EXPR:
case FIX_TRUNC_EXPR:
/* Even if we're not being pedantic, we cannot allow this
extension when we're instantiating in a SFINAE
context. */
if (! lvalue_p (arg) && complain == tf_none)
{
if (complain & tf_error)
permerror (input_location, "ISO C++ forbids taking the address of a cast to a non-lvalue expression");
else
return error_mark_node;
}
/* We should have handled this above in the lvalue_kind check. */
gcc_unreachable ();
break;
case BASELINK:
@ -7240,9 +7232,7 @@ build_const_cast_1 (tree dst_type, tree expr, tsubst_flags_t complain,
reference_type = dst_type;
if (!TYPE_REF_IS_RVALUE (dst_type)
? real_lvalue_p (expr)
: (CLASS_TYPE_P (TREE_TYPE (dst_type))
? lvalue_p (expr)
: glvalue_p (expr)))
: obvalue_p (expr))
/* OK. */;
else
{