This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/48062] `shadowed declaration is here' should be a note
- From: "momchil at xaxo dot eu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 9 Jun 2011 01:46:45 +0000
- Subject: [Bug c/48062] `shadowed declaration is here' should be a note
- Auto-submitted: auto-generated
- References: <bug-48062-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48062
momchil at xaxo dot eu changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |momchil at xaxo dot eu
--- Comment #2 from momchil at xaxo dot eu 2011-06-09 01:46:43 UTC ---
Hi, there is an ambiguity here, consider the following examples:
$ cat > 1.c
int
main(void)
{
int i;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
{ int i; }
#pragma GCC diagnostic pop
}
$ gcc46 -Wshadow 1.c
1.c: In function 'main':
1.c:4:6: warning: shadowed declaration is here [-Wshadow]
Here I would suppose to see no warning at all, because I have turned it off for
the case that shadows. But:
$ cat > 2.c
int
main(void)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
int i;
#pragma GCC diagnostic pop
{int i;}
}
$ gcc46 -Wshadow 2.c
2.c: In function 'main':
2.c:9:7: warning: declaration of 'i' shadows a previous local [-Wshadow]
And it is something that I whould also not expect. And now:
$ cat > 3.c
int
main(void)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
int i;
#pragma GCC diagnostic pop
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
{ int i; }
#pragma GCC diagnostic pop
}
$ gcc46 -Wshadow 3.c
Produces no warning. So for me it is a bit confusing, since the warning setting
refers to pieces of code and not to variables.