From c01df3c86f72656e44ec1952b4e8019961ed7a4a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez?= Date: Fri, 15 Sep 2017 19:22:35 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/decl2.c | 2 +- gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/g++.dg/other/anon-union4.C | 3 +++ gcc/testsuite/g++.old-deja/g++.law/union4.C | 2 +- gcc/testsuite/g++.old-deja/g++.other/anon1.C | 2 +- 6 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/anon-union4.C 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 -- 2.30.2