[PATCH] c++: Fix bogus "does not declare anything" warning (PR 66159)

Jason Merrill jason@redhat.com
Wed Jun 17 16:32:27 GMT 2020


On 6/15/20 3:40 PM, Jonathan Wakely wrote:
> Ping ...
> 
> 
> 
> G++ gives a bogus warning for 'struct A; using B = struct ::A;'
> complaining that the elaborated-type-specifier doesn't declare anything.
> That's true, but it's not trying to declare struct ::A, just refer to it
> unambiguously. Do not emit the warning unless we're actually parsing a
> declaration.
> 
> This also makes the relevant warning depend on -Wredundant-decls (which
> is not part of -Wall or -Wextra) so it can be disabled on the command
> line or by using #pragma. This means the warning will no longer be given
> by default, so some tests need -Wredundant-decls added.
> 
> gcc/cp/ChangeLog:
> 
> 	PR c++/66159
> 	* parser.c (cp_parser_elaborated_type_specifier): Do not warn
> 	unless in a declaration.  Make warning depend on
> 	WOPT_redundant_decls.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR c++/66159
> 	* g++.dg/parse/specialization1.C: Remove dg-warning.
> 	* g++.dg/warn/forward-inner.C: Add -Wredundant-decls. Check
> 	alias-declaration using elaborated-type-specifier.
> 	* g++.dg/warn/pr36999.C: Add -Wredundant-decls.
> 
> 
> Is it OK to make this warning no longer emitted by default, and not
> even with -Wall -Wextra?

I'd like to keep it on by default.

> Would it be better to add a new option for this specific warning,
> which would be enabled by -Wall and also by -Wredundant-decls? Maybe
> -Wredundant-decls-elaborated-type or something.

That sounds fine.  But do you think people will really want to turn this 
off after you fix the bug?

Jason



More information about the Gcc-patches mailing list