aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2012-05-25 23:40:10 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2012-05-25 23:40:10 +0000
commit6d199d3c08ec25787b76154a5d324d63561bccde (patch)
treea736b7bb0c69555be936b4eecea2f0e52228b0c8
parentd4dc840de43342b24006974f7899d127235adcba (diff)
downloadgcc-6d199d3c08ec25787b76154a5d324d63561bccde.zip
gcc-6d199d3c08ec25787b76154a5d324d63561bccde.tar.gz
gcc-6d199d3c08ec25787b76154a5d324d63561bccde.tar.bz2
re PR c++/32054 (Storage classes on anonymous unions in classes)
/cp 2012-05-25 Paolo Carlini <paolo.carlini@oracle.com> PR c++/32054 * parser.c (cp_parser_member_declaration): A storage class is not allowed in a declaration of an anonymous aggregate in a class scope. /testsuite 2012-05-25 Paolo Carlini <paolo.carlini@oracle.com> PR c++/32054 * g++.dg/other/anon-union3.C: New. From-SVN: r187902
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/other/anon-union3.C25
4 files changed, 42 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index daf1a6c..75c9e25 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-25 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/32054
+ * parser.c (cp_parser_member_declaration): A storage class is not
+ allowed in a declaration of an anonymous aggregate in a class scope.
+
2012-05-24 Uros Bizjak <ubizjak@gmail.com>
PR obj-c++/53441
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 165fdc2..9fd8c84 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -18910,6 +18910,12 @@ cp_parser_member_declaration (cp_parser* parser)
particular type), as opposed to a nested class. */
else if (ANON_AGGR_TYPE_P (type))
{
+ /* C++11 9.5/6. */
+ if (decl_specifiers.storage_class != sc_none)
+ error_at (decl_spec_token_start->location,
+ "a storage class on an anonymous aggregate "
+ "in class scope is not allowed");
+
/* Remove constructors and such from TYPE, now that we
know it is an anonymous aggregate. */
fixup_anonymous_aggr (type);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 285ae9c..b873c67 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-25 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/32054
+ * g++.dg/other/anon-union3.C: New.
+
2012-05-25 Ian Lance Taylor <iant@google.com>
* gcc.dg/split-6.c: New test.
diff --git a/gcc/testsuite/g++.dg/other/anon-union3.C b/gcc/testsuite/g++.dg/other/anon-union3.C
new file mode 100644
index 0000000..e65ee94
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/anon-union3.C
@@ -0,0 +1,25 @@
+// PR c++/32054
+
+class C
+{
+ auto union // { dg-error "storage class" "" { target c++98 } }
+ {
+ int a;
+ }; // { dg-error "multiple|specified" "" { target c++11 } }
+ register union // { dg-error "storage class" }
+ {
+ int b;
+ };
+ static union // { dg-error "storage class" }
+ {
+ int c;
+ };
+ extern union // { dg-error "storage class" }
+ {
+ int d;
+ };
+ mutable union // { dg-error "storage class" }
+ {
+ int e;
+ };
+};