Warning from -Wshadow should indicate the location of the definition of the variable being shadowed
Lakshmankumar Mukkavilli
lakshman@cisco.com
Wed Nov 7 09:26:00 GMT 2001
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
More information about the Gcc-bugs
mailing list