Commit 0171567e by Jason Merrill Committed by Jason Merrill

re PR c++/49389 ([C++0x] Wrong value category for pointer-to-member expression…

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
parent 2bbf86a4
2011-06-14 Jason Merrill <jason@redhat.com> 2011-06-14 Jason Merrill <jason@redhat.com>
PR c++/49389
* typeck2.c (build_m_component_ref): Preserve rvalueness.
PR c++/49369 PR c++/49369
* class.c (build_base_path): Fix cv-quals in unevaluated context. * class.c (build_base_path): Fix cv-quals in unevaluated context.
......
...@@ -1551,6 +1551,7 @@ build_m_component_ref (tree datum, tree component) ...@@ -1551,6 +1551,7 @@ build_m_component_ref (tree datum, tree component)
if (TYPE_PTRMEM_P (ptrmem_type)) if (TYPE_PTRMEM_P (ptrmem_type))
{ {
bool is_lval = real_lvalue_p (datum);
tree ptype; tree ptype;
/* Compute the type of the field, as described in [expr.ref]. /* Compute the type of the field, as described in [expr.ref].
...@@ -1573,7 +1574,11 @@ build_m_component_ref (tree datum, tree component) ...@@ -1573,7 +1574,11 @@ build_m_component_ref (tree datum, tree component)
datum = build2 (POINTER_PLUS_EXPR, ptype, datum = build2 (POINTER_PLUS_EXPR, ptype,
fold_convert (ptype, datum), fold_convert (ptype, datum),
build_nop (sizetype, component)); 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 else
return build2 (OFFSET_REF, type, datum, component); return build2 (OFFSET_REF, type, datum, component);
......
2011-06-14 Jason Merrill <jason@redhat.com> 2011-06-14 Jason Merrill <jason@redhat.com>
PR c++/49389
* g++.dg/cpp0x/rv-dotstar.C: New.
PR c++/49369 PR c++/49369
* g++.dg/cpp0x/decltype30.C: New. * g++.dg/cpp0x/decltype30.C: New.
......
// 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment