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 c0132251edc6c7613011593570a74f3ddabfd91f..b43f042673631bfecc828ec5378b77309363f656 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 2bde588847e9ed1a750e9165e181159bd049fc4c..03e91b7e150ae4af959d128ce1ed41192059315d 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 0091855e2c9607f6bce1d18938bd1168fd5cd282..574251590f9525907748c7ed7ba8793ed780cc09 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 f48ceeea267f757c2a7516d22415c6abcd4ac3a3..958ff0afe5b4b8b76ef363a770236f1dd09247c1 100644 (file)
@@ -10,4 +10,4 @@ static union {
         struct SS {
                 int ss;
         };
-};// { dg-warning "no members" }
+};// { dg-error "no members" }
index 5886b1a714d24723351b0269c706bbb66d50a900..70ae600a3dd12e61e339b5605d437d39a4e19e5d 100644 (file)
@@ -3,4 +3,4 @@
 static union {
   union {
   };
-}; // { dg-warning "" } anonymous union with no members
+}; // { dg-error "" } anonymous union with no members