aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-06-14 14:15:58 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-06-14 14:15:58 -0400
commit0171567edce496309e2a364e563b7cf066923918 (patch)
tree300061c01b7df3453d9339e24a044912ddc6672a /gcc/cp
parent2bbf86a46bdece05107c54d94c4c8d41a2d17023 (diff)
downloadgcc-0171567edce496309e2a364e563b7cf066923918.zip
gcc-0171567edce496309e2a364e563b7cf066923918.tar.gz
gcc-0171567edce496309e2a364e563b7cf066923918.tar.bz2
re PR c++/49389 ([C++0x] Wrong value category for pointer-to-member expression with rvalue object expression)
PR c++/49389 * typeck2.c (build_m_component_ref): Preserve rvalueness. From-SVN: r175043
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/typeck2.c7
2 files changed, 9 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a6c8665..5970440 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2011-06-14 Jason Merrill <jason@redhat.com>
+ PR c++/49389
+ * typeck2.c (build_m_component_ref): Preserve rvalueness.
+
PR c++/49369
* class.c (build_base_path): Fix cv-quals in unevaluated context.
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index fa64d1d..d72f57e 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1551,6 +1551,7 @@ build_m_component_ref (tree datum, tree component)
if (TYPE_PTRMEM_P (ptrmem_type))
{
+ bool is_lval = real_lvalue_p (datum);
tree ptype;
/* Compute the type of the field, as described in [expr.ref].
@@ -1573,7 +1574,11 @@ build_m_component_ref (tree datum, tree component)
datum = build2 (POINTER_PLUS_EXPR, ptype,
fold_convert (ptype, datum),
build_nop (sizetype, component));
- return cp_build_indirect_ref (datum, RO_NULL, tf_warning_or_error);
+ datum = cp_build_indirect_ref (datum, RO_NULL, tf_warning_or_error);
+ /* If the object expression was an rvalue, return an rvalue. */
+ if (!is_lval)
+ datum = move (datum);
+ return datum;
}
else
return build2 (OFFSET_REF, type, datum, component);