diff options
author | Jason Merrill <jason@redhat.com> | 2010-07-19 21:31:42 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-07-19 21:31:42 -0400 |
commit | 8145be0145861ae60c43d96ef9ff726e9cd644f6 (patch) | |
tree | 247898b0a0178d1e6b93a27d23c1df0913f0786f | |
parent | 27728d816f2c0e081ab1756b43871f86bdeb2a0f (diff) | |
download | gcc-8145be0145861ae60c43d96ef9ff726e9cd644f6.zip gcc-8145be0145861ae60c43d96ef9ff726e9cd644f6.tar.gz gcc-8145be0145861ae60c43d96ef9ff726e9cd644f6.tar.bz2 |
re PR c++/44996 ([C++0x] decltype produces rvalue reference type for parenthesized id-expression)
PR c++/44996
* semantics.c (finish_decltype_type): Correct decltype
of parenthesized rvalue reference variable.
From-SVN: r162323
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/decltype23.C | 5 |
4 files changed, 17 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9a7c1a4..124fbe2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2010-07-19 Jason Merrill <jason@redhat.com> + PR c++/44996 + * semantics.c (finish_decltype_type): Correct decltype + of parenthesized rvalue reference variable. + PR c++/44969 * tree.c (cp_tree_equal): Compare type of *CAST_EXPR. * pt.c (iterative_hash_template_arg): Hash type of *CAST_EXPR. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index a39e0b8..949e108 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4899,8 +4899,9 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) type = TYPE_MAIN_VARIANT (type); else if (real_lvalue_p (expr)) { - if (TREE_CODE (type) != REFERENCE_TYPE) - type = build_reference_type (type); + if (TREE_CODE (type) != REFERENCE_TYPE + || TYPE_REF_IS_RVALUE (type)) + type = build_reference_type (non_reference (type)); } else type = non_reference (type); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e266814..aa5b316 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-07-19 Jason Merrill <jason@redhat.com> + + PR c++/44996 + * g++.dg/cpp0x/decltype23.C: New. + 2010-07-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/42385 diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype23.C b/gcc/testsuite/g++.dg/cpp0x/decltype23.C new file mode 100644 index 0000000..78eb89d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype23.C @@ -0,0 +1,5 @@ +// { dg-options -std=c++0x } + +int x, &&y = static_cast<int &&>(x); +typedef decltype((y)) myInt; // `y' is a parenthesized id-expression of type int that is an lvalue +typedef int &myInt; |