This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Warning from -Wshadow should indicate the location of the definition of the variable being shadowed
- From: Lakshmankumar Mukkavilli <lakshman at cisco dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Cc: lakshman at cisco dot com
- Date: Mon, 19 Nov 2001 09:12:39 -0800
- Subject: Warning from -Wshadow should indicate the location of the definition of the variable being shadowed
- Organization: Cisco Systems
[Get raw message]
This is not a bug but a request for additional information while
reporting problems about shadowing variables.
gcc -c -Wshadow test.c
produces a warning
t.c: In function `myfunction':
t.c:5: warning: declaration of `myvar' shadows global declaration
This gives no indication of where 'myvar' is defined in the enclosing
scope. In small programs this causes no problem. But when used in
programs where the preprocessed files have tens of thousands of lines
and scores of files are included locating the definition of the variable
being shadowed is tedious and time-consuming.
gcc -v output:
Thread model: posix
gcc version 3.0.1 20010801 (prerelease)
I have checked with other releases and results are not different.
'uname -a ' output
SunOS myhost 5.6 Generic_105181-21 sun4u sparc SUNW,Ultra-Enterprise
My test.c (just for illustration):
int myvar;
void myfunction ()
{
char myvar;
myvar='a';
}
Will be happy to provide any further info I may have missed.
Regards,
Lakshmankumar Mukkavilli
lakshman@cisco.com