This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Warning from -Wshadow should indicate the location of the definition of the variable being shadowed
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- To: Lakshmankumar Mukkavilli <lakshman at cisco dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 5 Dec 2001 23:14:06 +0000
- Subject: Re: Warning from -Wshadow should indicate the location of the definition of the variable being shadowed
- References: <3BF93D87.6C1DCEC4@cisco.com>
I've just committed a patch to do this in 3.1 CVS.
Lakshmankumar Mukkavilli wrote:-
> My test.c (just for illustration):
> int myvar;
>
> void myfunction ()
> {
> char myvar;
>
> myvar='a';
> }
This example now gives:
$ gcc -Wshadow /tmp/foo.c -c
/tmp/foo.c: In function `myfunction':
/tmp/foo.c:5: warning: declaration of `myvar' shadows a global declaration
/tmp/foo.c:1: warning: shadowed declaration is here
$