re PR c++/64644 ("warning: anonymous union with no members" should be an error with...
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Fri, 15 Sep 2017 19:22:35 +0000 (19:22 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 15 Sep 2017 19:22:35 +0000 (19:22 +0000)
/cp
2017-09-15  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
    Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/64644
* decl2.c (finish_anon_union): Complain about "anonymous union with
no members" with a pedwarn.

/testsuite
2017-09-15  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
    Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/64644
* g++.dg/other/anon-union4.C: New.
* g++.old-deja/g++.law/union4.C: Adjust.
* g++.old-deja/g++.other/anon1.C: Likewise.

Co-Authored-By: Paolo Carlini <paolo.carlini@oracle.com>
From-SVN: r252835

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/anon-union4.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.law/union4.C
gcc/testsuite/g++.old-deja/g++.other/anon1.C

index c013225..b43f042 100644 (file)
@@ -1,3 +1,10 @@
+2017-09-15  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+           Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/64644
+       * decl2.c (finish_anon_union): Complain about "anonymous union with
+       no members" with a pedwarn.
+
 2017-09-15  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        * typeck.c (build_reinterpret_cast_1,
index 2bde588..03e91b7 100644 (file)
@@ -1546,7 +1546,7 @@ finish_anon_union (tree anon_union_decl)
     return;
   if (main_decl == NULL_TREE)
     {
-      warning (0, "anonymous union with no members");
+      pedwarn (input_location, 0, "anonymous union with no members");
       return;
     }
 
index 0091855..5742515 100644 (file)
@@ -1,3 +1,11 @@
+2017-09-15  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+           Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/64644
+       * g++.dg/other/anon-union4.C: New.
+       * g++.old-deja/g++.law/union4.C: Adjust.
+       * g++.old-deja/g++.other/anon1.C: Likewise.
+
 2017-09-15  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        * c-c++-common/Wcast-align.c: New test.
diff --git a/gcc/testsuite/g++.dg/other/anon-union4.C b/gcc/testsuite/g++.dg/other/anon-union4.C
new file mode 100644 (file)
index 0000000..043c208
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/64644
+
+static union { };  // { dg-error "anonymous union with no members" }
index f48ceee..958ff0a 100644 (file)
@@ -10,4 +10,4 @@ static union {
         struct SS {
                 int ss;
         };
-};// { dg-warning "no members" }
+};// { dg-error "no members" }
index 5886b1a..70ae600 100644 (file)
@@ -3,4 +3,4 @@
 static union {
   union {
   };
-}; // { dg-warning "" } anonymous union with no members
+}; // { dg-error "" } anonymous union with no members