This is the mail archive of the gcc-prs@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]

c++/9400: Warning -Wshadow warns of shadowed declaration of THIS in local classes.


>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:


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