This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR c/53066 Wshadow should not warn for shadowing an extern function
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Tue, 24 Apr 2012 22:01:12 +0000 (UTC)
- Subject: Re: PR c/53066 Wshadow should not warn for shadowing an extern function
- References: <CAESRpQDQcYaLn4Dp0PJeH5sC9vT5AMrzJFv6WJLsd5UAe8J6tw@mail.gmail.com>
On Sun, 22 Apr 2012, Manuel López-Ibáñez wrote:
> Wshadow warns whenever any declaration shadows a global function
> declaration. This is almost always noise, since most (always?) of the
> time one cannot mistakenly replace a function by another variable. The
> false positives are too common (Linus mentions using the name 'index'
> when including string.h).
I think the correct rule would be: warn if a variable *with
pointer-to-function type* shadows a function, and warn if a nested
function shadows another function, but don't warn for variables shadowing
functions if the variable has any other type (because if the variable has
some type that isn't a pointer-to-function, no confusion is likely without
another error being given).
--
Joseph S. Myers
joseph@codesourcery.com