From: Manuel López-Ibáñez Date: Fri, 15 Sep 2017 19:22:35 +0000 (+0000) Subject: re PR c++/64644 ("warning: anonymous union with no members" should be an error with... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c01df3c86f72656e44ec1952b4e8019961ed7a4a;p=gcc.git re PR c++/64644 ("warning: anonymous union with no members" should be an error with -pedantic-errors) /cp 2017-09-15 Manuel Lopez-Ibanez Paolo Carlini 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 Paolo Carlini 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 From-SVN: r252835 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c0132251edc..b43f0426736 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2017-09-15 Manuel Lopez-Ibanez + Paolo Carlini + + PR c++/64644 + * decl2.c (finish_anon_union): Complain about "anonymous union with + no members" with a pedwarn. + 2017-09-15 Bernd Edlinger * typeck.c (build_reinterpret_cast_1, diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 2bde588847e..03e91b7e150 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0091855e2c9..574251590f9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-09-15 Manuel Lopez-Ibanez + Paolo Carlini + + 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 * 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 index 00000000000..043c2080b38 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/anon-union4.C @@ -0,0 +1,3 @@ +// PR c++/64644 + +static union { }; // { dg-error "anonymous union with no members" } diff --git a/gcc/testsuite/g++.old-deja/g++.law/union4.C b/gcc/testsuite/g++.old-deja/g++.law/union4.C index f48ceeea267..958ff0afe5b 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/union4.C +++ b/gcc/testsuite/g++.old-deja/g++.law/union4.C @@ -10,4 +10,4 @@ static union { struct SS { int ss; }; -};// { dg-warning "no members" } +};// { dg-error "no members" } diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon1.C b/gcc/testsuite/g++.old-deja/g++.other/anon1.C index 5886b1a714d..70ae600a3dd 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/anon1.C +++ b/gcc/testsuite/g++.old-deja/g++.other/anon1.C @@ -3,4 +3,4 @@ static union { union { }; -}; // { dg-warning "" } anonymous union with no members +}; // { dg-error "" } anonymous union with no members