re PR c++/9400 (Warning -Wshadow warns of shadowed declaration of THIS in local classes.)
authorMark Mitchell <mark@codesourcery.com>
Thu, 6 Mar 2003 21:10:38 +0000 (21:10 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 6 Mar 2003 21:10:38 +0000 (21:10 +0000)
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.

From-SVN: r63904

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wshadow-2.C [new file with mode: 0644]

index 7d62350a0a41cc554fcbcaf3d68837bf3482c8c4..94fb8840fcb978843d90c585274ea65151f324a2 100644 (file)
@@ -1,5 +1,9 @@
 2003-03-06  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/9400
+       * decl.c (pushdecl): Don't check for shadowing of DECL_ARTIFICIAL
+       PARM_DECLs.
+
        PR c++/9791
        * class.c (get_basefndecls): Use lookup_fnfields_1.
 
index a320ef0615c9ca42d1f9f98c2d10f0c64c8f172f..fb3631329e2724d9d54ac904749d2b78887344a3 100644 (file)
@@ -4101,7 +4101,9 @@ pushdecl (tree x)
          if (oldlocal != NULL_TREE && !DECL_EXTERNAL (x)
              /* Inline decls shadow nothing.  */
              && !DECL_FROM_INLINE (x)
-             && TREE_CODE (oldlocal) == PARM_DECL)
+             && TREE_CODE (oldlocal) == PARM_DECL
+             /* Don't check the `this' parameter.  */
+             && !DECL_ARTIFICIAL (oldlocal))
            {
              bool err = false;
 
index 1b7c6d38bb6681616f9673dd6c3d6cad36c34c45..964228f7d557297d334c8669ca6d6ec18e371ddd 100644 (file)
@@ -1,5 +1,8 @@
 2003-03-06  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/9400
+       * g++.dg/warn/Wshadow-2.C: New test.
+
        PR c++/9791
        * g++.dg/warn/Woverloaded-1.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-2.C b/gcc/testsuite/g++.dg/warn/Wshadow-2.C
new file mode 100644 (file)
index 0000000..a3e9428
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-options "-Wshadow" } */
+
+struct A {
+  void a1 () {
+    struct B { B() {} }; // There should be no warning here.
+  }
+  void a2 () {
+      struct B { };
+  }
+};