aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-05-25 22:22:39 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-05-25 22:22:39 -0400
commitdc31ddad44bb44e5f715d0f730e16166621c573c (patch)
treea845c19be29011eba05cfde1421316ea1c0cfb88 /gcc
parentc688bbdd6366d12d98c95f18909c15f2c855eb99 (diff)
downloadgcc-dc31ddad44bb44e5f715d0f730e16166621c573c.zip
gcc-dc31ddad44bb44e5f715d0f730e16166621c573c.tar.gz
gcc-dc31ddad44bb44e5f715d0f730e16166621c573c.tar.bz2
re PR c++/45401 ([C++0x] reference collapsing and reference qualifiers)
PR c++/45401 * decl.c (grokdeclarator): Don't change type when adding rvalue ref to another reference type. From-SVN: r174255
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl.c17
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/rv-restrict.C6
4 files changed, 23 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1b61193..1d0aa92 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2011-05-25 Jason Merrill <jason@redhat.com>
+ PR c++/45401
+ * decl.c (grokdeclarator): Don't change type when adding rvalue ref
+ to another reference type.
+
PR c++/44311
* decl.c (case_conversion): New.
(finish_case_label): Use it.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 7fc1945..d53fa26 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9200,13 +9200,18 @@ grokdeclarator (const cp_declarator *declarator,
to create the type "rvalue reference to cv TD' creates the
type TD."
*/
- if (!VOID_TYPE_P (type))
+ if (VOID_TYPE_P (type))
+ /* We already gave an error. */;
+ else if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ if (declarator->u.reference.rvalue_ref)
+ /* Leave type alone. */;
+ else
+ type = cp_build_reference_type (TREE_TYPE (type), false);
+ }
+ else
type = cp_build_reference_type
- ((TREE_CODE (type) == REFERENCE_TYPE
- ? TREE_TYPE (type) : type),
- (declarator->u.reference.rvalue_ref
- && (TREE_CODE(type) != REFERENCE_TYPE
- || TYPE_REF_IS_RVALUE (type))));
+ (type, declarator->u.reference.rvalue_ref);
/* In C++0x, we need this check for direct reference to
reference declarations, which are forbidden by
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e8a335f..e302c74 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,7 @@
2011-05-25 Jason Merrill <jason@redhat.com>
+ * g++.dg/cpp0x/rv-restrict.C: New.
+
* g++.dg/cpp0x/enum15.C: New.
* g++.dg/cpp0x/constexpr-switch2.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-restrict.C b/gcc/testsuite/g++.dg/cpp0x/rv-restrict.C
new file mode 100644
index 0000000..569ee5b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-restrict.C
@@ -0,0 +1,6 @@
+// PR c++/45401
+// { dg-options -std=c++0x }
+
+typedef int &__restrict restrictLvref;
+typedef restrictLvref &&rvrefToRestrictLvref;
+typedef restrictLvref rvrefToRestrictLvref;