Bug 9400 - [3.2 regression] Warning -Wshadow warns of shadowed declaration of THIS in local classes.
Summary: [3.2 regression] Warning -Wshadow warns of shadowed declaration of THIS in lo...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-22 12:56 UTC by merkert
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description merkert 2003-01-22 12:56:00 UTC
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.

Release:
GCC 3.1

How-To-Repeat:
cat > test.cpp <<EOF
struct A {
  void a1 () {
        struct B { B() {} };
  }
  void a2 () {
      struct B { };
  }
};
EOF
gcc -c -Wshadow test.cpp
Comment 1 merkert 2003-01-22 12:56:00 UTC
Fix:
Fixed in GCC 3.3 with:

  http://gcc.gnu.org/ml/gcc-patches/2003-03/msg00556.html
Comment 2 Wolfgang Bangerth 2003-01-22 14:57:47 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. Indeed a funny error...
    
    This used to not warn until 3.0, but does so with present
    3.2, 3.3, and 3.4 CVS, so it's kind of a regression.
    
    W:
Comment 3 Mark Mitchell 2003-03-06 21:10:38 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/9400
Date: 6 Mar 2003 21:10:38 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2003-03-06 21:10:38
 
 Modified files:
 	gcc/cp         : ChangeLog decl.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/warn: Wshadow-2.C 
 
 Log message:
 	PR c++/9400
 	* decl.c (pushdecl): Don't check for shadowing of DECL_ARTIFICIAL
 	PARM_DECLs.
 	
 	PR c++/9400
 	* g++.dg/warn/Wshadow-2.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3239&r2=1.3240
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1014&r2=1.1015
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2473&r2=1.2474
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wshadow-2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 

Comment 4 Mark Mitchell 2003-03-06 21:10:38 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/9400
Date: 6 Mar 2003 21:10:38 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2003-03-06 21:10:38
 
 Modified files:
 	gcc/cp         : ChangeLog decl.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/warn: Wshadow-2.C 
 
 Log message:
 	PR c++/9400
 	* decl.c (pushdecl): Don't check for shadowing of DECL_ARTIFICIAL
 	PARM_DECLs.
 	
 	PR c++/9400
 	* g++.dg/warn/Wshadow-2.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3239&r2=1.3240
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1014&r2=1.1015
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2473&r2=1.2474
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wshadow-2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 

Comment 5 Mark Mitchell 2003-03-06 21:12:14 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/9400
Date: 6 Mar 2003 21:12:14 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	mmitchel@gcc.gnu.org	2003-03-06 21:12:14
 
 Modified files:
 	gcc/cp         : decl.c 
 Added files:
 	gcc/testsuite/g++.dg/warn: Wshadow-2.C 
 
 Log message:
 	PR c++/9400
 	* decl.c (pushdecl): Don't check for shadowing of DECL_ARTIFICIAL
 	PARM_DECLs.
 	
 	PR c++/9400
 	* g++.dg/warn/Wshadow-2.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.24&r2=1.965.2.25
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wshadow-2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
 

Comment 6 Mark Mitchell 2003-03-06 21:12:14 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/9400
Date: 6 Mar 2003 21:12:14 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	mmitchel@gcc.gnu.org	2003-03-06 21:12:14
 
 Modified files:
 	gcc/cp         : decl.c 
 Added files:
 	gcc/testsuite/g++.dg/warn: Wshadow-2.C 
 
 Log message:
 	PR c++/9400
 	* decl.c (pushdecl): Don't check for shadowing of DECL_ARTIFICIAL
 	PARM_DECLs.
 	
 	PR c++/9400
 	* g++.dg/warn/Wshadow-2.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.24&r2=1.965.2.25
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wshadow-2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
 

Comment 7 Mark Mitchell 2003-03-06 21:12:52 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/9400
Date: 6 Mar 2003 21:12:52 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	mmitchel@gcc.gnu.org	2003-03-06 21:12:52
 
 Modified files:
 	gcc/cp         : ChangeLog 
 	gcc/testsuite  : ChangeLog 
 
 Log message:
 	PR c++/9400
 	* decl.c (pushdecl): Don't check for shadowing of DECL_ARTIFICIAL
 	PARM_DECLs.
 	
 	PR c++/9400
 	* g++.dg/warn/Wshadow-2.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.58&r2=1.3076.2.59
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.73&r2=1.2261.2.74
 

Comment 8 Mark Mitchell 2003-03-06 21:12:52 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/9400
Date: 6 Mar 2003 21:12:52 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	mmitchel@gcc.gnu.org	2003-03-06 21:12:52
 
 Modified files:
 	gcc/cp         : ChangeLog 
 	gcc/testsuite  : ChangeLog 
 
 Log message:
 	PR c++/9400
 	* decl.c (pushdecl): Don't check for shadowing of DECL_ARTIFICIAL
 	PARM_DECLs.
 	
 	PR c++/9400
 	* g++.dg/warn/Wshadow-2.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.58&r2=1.3076.2.59
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.73&r2=1.2261.2.74
 
Comment 9 Joe Buck 2003-04-25 21:18:10 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed for 3.3.