* 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
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.
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)
{
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);
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
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
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);
}
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
/* 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);
}
TREE_OPERAND (exp, 0), op1);
}
- if (!lvalue_p (exp)
+ if (!obvalue_p (exp)
&& ! (TREE_CODE (exp) == CONSTRUCTOR && TREE_STATIC (exp)))
{
if (complain & tf_error)
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:
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
{