This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Warning from -Wshadow should indicate the location of the definition of the variable being shadowed

[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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]