diff options
author | Jason Merrill <jason@redhat.com> | 2013-03-26 23:01:34 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2013-03-26 23:01:34 -0400 |
commit | 845367eb3b3a6845a603e2d959c85fba9ce921da (patch) | |
tree | b98d8fdea5669cee607206d34978fc40c25bc75b | |
parent | a323d79533d9380eae082e550fe9489046587562 (diff) | |
download | gcc-845367eb3b3a6845a603e2d959c85fba9ce921da.zip gcc-845367eb3b3a6845a603e2d959c85fba9ce921da.tar.gz gcc-845367eb3b3a6845a603e2d959c85fba9ce921da.tar.bz2 |
re PR c++/45282 (wrong decltype result for .*)
PR c++/45282
* typeck2.c (build_m_component_ref): Handle prvalue object.
From-SVN: r197130
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/decltype49.C | 10 |
3 files changed, 19 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8bddaf2..0c5bcee 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2013-03-26 Jason Merrill <jason@redhat.com> + + PR c++/45282 + * typeck2.c (build_m_component_ref): Handle prvalue object. + 2013-03-26 Gabriel Dos Reis <gdr@integrable-solutions.net> * cp-gimplify.c (cp_genericize_r): Use VAR_OR_FUNCTION_DECL_P. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index ca31610..72dccb4 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1671,7 +1671,7 @@ build_m_component_ref (tree datum, tree component, tsubst_flags_t complain) if (TYPE_PTRDATAMEM_P (ptrmem_type)) { - bool is_lval = real_lvalue_p (datum); + cp_lvalue_kind kind = lvalue_kind (datum); tree ptype; /* Compute the type of the field, as described in [expr.ref]. @@ -1701,7 +1701,9 @@ build_m_component_ref (tree datum, tree component, tsubst_flags_t complain) return error_mark_node; /* If the object expression was an rvalue, return an rvalue. */ - if (!is_lval) + if (kind & clk_class) + datum = rvalue (datum); + else if (kind & clk_rvalueref) datum = move (datum); return datum; } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype49.C b/gcc/testsuite/g++.dg/cpp0x/decltype49.C new file mode 100644 index 0000000..c317498 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype49.C @@ -0,0 +1,10 @@ +// PR c++/45282 +// { dg-require-effective-target c++11 } + +struct A { int i; }; +int A::*ipm = &A::i; + +template <class T, class U> class assert_same_type; +template <class T> class assert_same_type<T,T> { }; + +assert_same_type<decltype(A().*ipm),int> x2; |