OSDN Git Service

PR c++/9400
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Mar 2003 21:10:38 +0000 (21:10 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Mar 2003 21:10:38 +0000 (21:10 +0000)
* decl.c (pushdecl): Don't check for shadowing of DECL_ARTIFICIAL
PARM_DECLs.

PR c++/9400
* g++.dg/warn/Wshadow-2.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63904 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 7d62350..94fb884 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 a320ef0..fb36313 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 1b7c6d3..964228f 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 { };
+  }
+};