===================================================================
@@ -9210,6 +9210,12 @@ grokdeclarator (const cp_declarator *dec
error ("const %qs cannot be declared %<mutable%>", name);
storage_class = sc_none;
}
+ else if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ permerror (input_location, "reference %qs cannot be declared "
+ "%<mutable%>", name);
+ storage_class = sc_none;
+ }
}
/* If this is declaring a typedef name, return a TYPE_DECL. */
===================================================================
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+class X {
+ mutable int &q; /* { dg-error "cannot be declared 'mutable'" } */
+};
===================================================================
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-fpermissive" } */
+
+class X {
+ mutable int &q; /* { dg-warning "cannot be declared 'mutable'" } */
+};