This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/9400: Warning -Wshadow warns of shadowed declaration of THIS in local classes.
- From: Raimond_Merkert at raytheon dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 22 Jan 2003 12:50:49 -0000
- Subject: c++/9400: Warning -Wshadow warns of shadowed declaration of THIS in local classes.
- Reply-to: Raimond_Merkert at raytheon dot com
>Number: 9400
>Category: c++
>Synopsis: Warning -Wshadow warns of shadowed declaration of THIS in local classes.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jan 22 12:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Raimond_Merkert@raytheon.com
>Release: GCC 3.1
>Organization:
>Environment:
>Description:
When compiling the test code with "gcc -c -Wshadow", the following warning is emitted:
test.cpp: In constructor `A::a1()::B::B()':
test.cpp:5: warning: declaration of `this' shadows a parameter
test.cpp:3: warning: shadowed declaration is here
Note that this warning is not emitted if I don't declare a constructor in the local class (as in A::a2())
I think the warning should always be suppressed if 'this' is involved since it it not a variable as such.
I've observed this behaviour in the gcc 3.3 prerelease snapshot from 2003-01-13 as well. I've also observed it on Linux and Solaris.
>How-To-Repeat:
cat > test.cpp <<EOF
struct A {
void a1 () {
struct B { B() {} };
}
void a2 () {
struct B { };
}
};
EOF
gcc -c -Wshadow test.cpp
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: