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: Mon, 19 Nov 2001 22:53:11 +0000
- Subject: Re: Warning from -Wshadow should indicate the location of the definition of the variable being shadowed
- References: <3BF93D87.6C1DCEC4@cisco.com>
[Get raw message]
Lakshmankumar Mukkavilli wrote:-
> 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.
Good point. I recently changed the C++ front end to do this.
However, the C front end still does not. I hope to get round to doing
the C front end too before 3.1.
Neil.