OSDN Git Service

2011-01-15 Giovanni Funchal <gafunchal@gmail.com>
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 15 Jan 2011 14:41:09 +0000 (14:41 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 15 Jan 2011 14:41:09 +0000 (14:41 +0000)
    Jonathan Wakely  <jwakely.gcc@gmail.com>

PR c++/33558
* decl.c (grokdeclarator): Reject mutable reference members.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168843 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr33558-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/pr33558.C [new file with mode: 0644]

index 22f5bf0..e7b45b4 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-15  Giovanni Funchal  <gafunchal@gmail.com>
+           Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       PR c++/33558
+       * decl.c (grokdeclarator): Reject mutable reference members.
+
 2011-01-14  Jason Merrill  <jason@redhat.com>
 
        PR c++/47289
index f7bf1bf..6a13cc4 100644 (file)
@@ -9214,6 +9214,12 @@ grokdeclarator (const cp_declarator *declarator,
          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.  */
index b1d5a5f..b30e532 100644 (file)
@@ -1,3 +1,10 @@
+2011-01-15  Giovanni Funchal  <gafunchal@gmail.com>
+           Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       PR c++/33558
+       * g++.dg/other/pr33558.C: New.
+       * g++.dg/other/pr33558-2.C: New.
+
 2011-01-14  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/45934
diff --git a/gcc/testsuite/g++.dg/other/pr33558-2.C b/gcc/testsuite/g++.dg/other/pr33558-2.C
new file mode 100644 (file)
index 0000000..a8df840
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-fpermissive" } */
+
+class X {
+  mutable int &q; /* { dg-warning "cannot be declared 'mutable'" } */
+};
diff --git a/gcc/testsuite/g++.dg/other/pr33558.C b/gcc/testsuite/g++.dg/other/pr33558.C
new file mode 100644 (file)
index 0000000..1a340af
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+class X {
+  mutable int &q; /* { dg-error "cannot be declared 'mutable'" } */
+};