re PR c++/33558 ('mutable' incorrectly accepted on reference members)

2011-01-15  Giovanni Funchal  <gafunchal@gmail.com>
	    Jonathan Wakely  <jwakely.gcc@gmail.com>

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


Co-Authored-By: Jonathan Wakely <jwakely.gcc@gmail.com>

From-SVN: r168843
This commit is contained in:
Giovanni Funchal 2011-01-15 14:41:09 +00:00 committed by Jonathan Wakely
parent 050d1a59d1
commit 620437f2d4
5 changed files with 30 additions and 0 deletions

View 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

View 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. */

View 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

View File

@ -0,0 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-fpermissive" } */
class X {
mutable int &q; /* { dg-warning "cannot be declared 'mutable'" } */
};

View File

@ -0,0 +1,5 @@
/* { dg-do compile } */
class X {
mutable int &q; /* { dg-error "cannot be declared 'mutable'" } */
};