summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-14 18:15:58 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-14 18:15:58 +0000
commit0277b639978dd399114465befd4000016f53526e (patch)
tree300061c01b7df3453d9339e24a044912ddc6672a /gcc
parent5a066ec2d5d960f9d2649a9113ab829acb681cba (diff)
downloadgcc-0277b639978dd399114465befd4000016f53526e.tar.gz
PR c++/49389
* typeck2.c (build_m_component_ref): Preserve rvalueness. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@175043 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/typeck2.c7
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/rv-dotstar.C13
4 files changed, 25 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a6c866567b8..5970440731f 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 fa64d1d7253..d72f57ec937 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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7d5e46ae7c8..1ca37e3490d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2011-06-14 Jason Merrill <jason@redhat.com>
+ PR c++/49389
+ * g++.dg/cpp0x/rv-dotstar.C: New.
+
PR c++/49369
* g++.dg/cpp0x/decltype30.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-dotstar.C b/gcc/testsuite/g++.dg/cpp0x/rv-dotstar.C
new file mode 100644
index 00000000000..65aac8da2a1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-dotstar.C
@@ -0,0 +1,13 @@
+// PR c++/49389
+// { dg-options -std=c++0x }
+
+template<class T> T&& val();
+
+struct A {};
+
+typedef decltype(val<A>().*val<int A::*>()) type;
+
+template<class> struct assert_type;
+template<> struct assert_type<int&&> {};
+
+assert_type<type> test;