aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c5
-rw-r--r--gcc/cp/cp-tree.h5
-rw-r--r--gcc/cp/cvt.c4
-rw-r--r--gcc/cp/init.c2
-rw-r--r--gcc/cp/tree.c10
-rw-r--r--gcc/cp/typeck.c18
7 files changed, 31 insertions, 19 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 98fb41a..8d8535d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 8509566..c90b8af 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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)
{
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 81f4a05..a3e53a9 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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);
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 2e2bac7..9dd383e 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -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
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index a71c21a..69ff61d 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -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);
}
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 57da88f..9fda74d 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -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);
}
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 005fc04..a0e6c51 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -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
{