https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66159
--- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #3) > Patch for stage 1: > > diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c > index 4fa546a086c..4dc4e751b28 100644 > --- a/gcc/cp/parser.c > +++ b/gcc/cp/parser.c > @@ -17818,9 +17818,11 @@ cp_parser_elaborated_type_specifier (cp_parser* > parser, > caught elsewhere in parsing. Those that are pointless arrive > here. */ > > - if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON) > + if (warn_redundant_decls > + && cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON) > && !is_friend && !processing_explicit_instantiation) > - warning (0, "declaration %qD does not declare anything", decl); > + warning (OPT_Wredundant_decls, > + "declaration %qD does not declare anything", decl); > > type = TREE_TYPE (decl); > } > diff --git a/gcc/testsuite/g++.dg/warn/forward-inner.C > b/gcc/testsuite/g++.dg/warn/forward-inner.C > index 5336d4ed946..f720a6cdae3 100644 > --- a/gcc/testsuite/g++.dg/warn/forward-inner.C > +++ b/gcc/testsuite/g++.dg/warn/forward-inner.C > @@ -1,5 +1,6 @@ > // Check that the compiler warns about inner-style forward declarations in > // contexts where they're not actually illegal, but merely useless. > +// { dg-options "-Wredundant-decls" } > > // Verify warnings for and within classes, and by extension, struct and > union. > class C1; > @@ -70,7 +71,7 @@ template class TC6<int>::TC7; // Valid explicit > instantiation, no warning > > > // Verify that friend declarations, also easy to confuse with forward > -// declrations, are similarly not warned about. > +// declarations, are similarly not warned about. > class C8 { > public: > class C9 { }; > @@ -79,3 +80,10 @@ class C10 { > public: > friend class C8::C9; // Valid friend declaration, no warning > }; > + > +#if __cplusplus >= 201103L > +// Verify that alias-declarations using an elaborated-type-specifier and > +// nested-name-specifier are not warned about (PR c++/66159). > +struct C11; > +using A1 = struct ::C11; > +#endif > diff --git a/gcc/testsuite/g++.dg/warn/pr36999.C > b/gcc/testsuite/g++.dg/warn/pr36999.C > index ce2286efcf4..6f69e192d02 100644 > --- a/gcc/testsuite/g++.dg/warn/pr36999.C > +++ b/gcc/testsuite/g++.dg/warn/pr36999.C > @@ -1,5 +1,6 @@ > /* PR36999: Erroneous "does not declare anything" warnings. */ > /* { dg-do compile } */ > +/* { dg-options "-Wredundant-decls" } */ > > class C1 { > public: class C2 { }; It's stage 1 now.