Commit c01df3c8 by Manuel López-Ibáñez Committed by Paolo Carlini

re PR c++/64644 ("warning: anonymous union with no members" should be an error…

re PR c++/64644 ("warning: anonymous union with no members" should be an error with -pedantic-errors)

/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
parent 39ebef2c
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> 2017-09-15 Bernd Edlinger <bernd.edlinger@hotmail.de>
* typeck.c (build_reinterpret_cast_1, * typeck.c (build_reinterpret_cast_1,
......
...@@ -1546,7 +1546,7 @@ finish_anon_union (tree anon_union_decl) ...@@ -1546,7 +1546,7 @@ finish_anon_union (tree anon_union_decl)
return; return;
if (main_decl == NULL_TREE) if (main_decl == NULL_TREE)
{ {
warning (0, "anonymous union with no members"); pedwarn (input_location, 0, "anonymous union with no members");
return; return;
} }
......
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> 2017-09-15 Bernd Edlinger <bernd.edlinger@hotmail.de>
* c-c++-common/Wcast-align.c: New test. * c-c++-common/Wcast-align.c: New test.
......
// PR c++/64644
static union { }; // { dg-error "anonymous union with no members" }
...@@ -10,4 +10,4 @@ static union { ...@@ -10,4 +10,4 @@ static union {
struct SS { struct SS {
int ss; int ss;
}; };
};// { dg-warning "no members" } };// { dg-error "no members" }
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
static union { static union {
union { union {
}; };
}; // { dg-warning "" } anonymous union with no members }; // { dg-error "" } anonymous union with no members
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment