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.
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
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.
--- /dev/null
+// PR c++/45401
+// { dg-options -std=c++0x }
+
+typedef int &__restrict restrictLvref;
+typedef restrictLvref &&rvrefToRestrictLvref;
+typedef restrictLvref rvrefToRestrictLvref;