OSDN Git Service

PR c++/45401
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 May 2011 03:06:09 +0000 (03:06 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 May 2011 03:06:09 +0000 (03:06 +0000)
* decl.c (grokdeclarator): Don't change type when adding rvalue ref
to another reference type.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174260 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/rv-restrict.C [new file with mode: 0644]

index 0c7e441..1ce050d 100644 (file)
@@ -1,3 +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.
+
 2011-05-26  Fabien ChĂȘne  <fabien@gcc.gnu.org>
        * init.c (diagnose_uninitialized_cst_or_ref_member_1): Use
        permerror instead of error, adjust the error count.
index de53541..b3de096 100644 (file)
@@ -9017,13 +9017,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
index 81fc5ab..418bb1d 100644 (file)
@@ -1,3 +1,7 @@
+2011-05-25  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/rv-restrict.C: New.
+
 2011-05-26  Fabien ChĂȘne  <fabien@gcc.gnu.org>
        * g++.dg/init/pr25811-2.C: New.
        * g++.dg/init/pr25811-3.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 (file)
index 0000000..569ee5b
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/45401
+// { dg-options -std=c++0x }
+
+typedef int &__restrict restrictLvref;
+typedef restrictLvref &&rvrefToRestrictLvref;
+typedef restrictLvref rvrefToRestrictLvref;