------- Comment #3 from jakub at gcc dot gnu dot org  2008-11-05 22:01 -------
I don't see any difference.  int (*fn) (int foo); declares a function pointer,
doesn't define a function, and how the argument is named also doesn't matter
much.  Only for:
int foo;
int baz (int foo)
{
  foo++;
}
the shadowing matters, but -Wshadow always warned even about parameter names
in prototypes and parameters of function pointers.  Actually, if you look at
PR37302, you can see that the warning might still make some sense when using
late return type or sizeof, typeof, alignof etc.
Consider:
int func (long foo, auto (*fn)(int foo) -> decltype (foo)); 
int bar (int);
void baz ()
{
  func(2, bar);
}
Here the shadowing, even inside of a prototype, matters a lot, if you change
int foo to int bar, then suddenly it won't compile, as bar doesn't return long.
And it makes sense to warn the user that he is shadowing the variable, because
it is unclear which foo was meant.
Or consider:
int func (long foo, int (*fn)(int foo, char (*bar)[sizeof (foo)]));
The same thing.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38022

Reply via email to