]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/39526 (-Wshadow reports shadowed declarations for parameters of unnamed...
authorJason Merrill <jason@redhat.com>
Mon, 23 Mar 2009 20:32:53 +0000 (16:32 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 23 Mar 2009 20:32:53 +0000 (16:32 -0400)
        PR c++/39526
        * name-lookup.c (pushdecl_maybe_friend): Don't warn about shadowing
        a parm with a parm.

From-SVN: r145012

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

index e695ede3f2dde9c95fec3aa5ee4b37c80c46664d..77c195a56c82492b57f8d41ed007ce5a96c211d2 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/39526
+       * name-lookup.c (pushdecl_maybe_friend): Don't warn about shadowing
+       a parm with a parm.
+
 2009-03-20  Jason Merrill  <jason@redhat.com>
 
        PR c++/28879
index 308df8c9c171f0b74de98dbcdd4716eb3dc682e5..6424569d7289ffb48e41b8d88fad36e39bf6824e 100644 (file)
@@ -1031,7 +1031,10 @@ pushdecl_maybe_friend (tree x, bool is_friend)
                    }
                }
 
-             if (warn_shadow && !err)
+             if (warn_shadow && !err
+                 /* Don't complain about the parms we push and then pop
+                    while tentatively parsing a function declarator.  */
+                 && !(TREE_CODE (x) == PARM_DECL && DECL_CONTEXT (x) == NULL_TREE))
                {
                  warning (OPT_Wshadow, "declaration of %q#D shadows a parameter", x);
                  warning (OPT_Wshadow, "%Jshadowed declaration is here", oldlocal);
index 65f77602a8b94fa2679528c63ff2869b5ced75a7..16a2c5478dfa71e5c5aaad6d63c5c79a9b52de25 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/39526
+       * g++.dg/warn/Wshadow-4.C: New test.
+
 2009-03-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/39516
diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-4.C b/gcc/testsuite/g++.dg/warn/Wshadow-4.C
new file mode 100644 (file)
index 0000000..16399b2
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/39526
+// { dg-options "-Wshadow" }
+
+class INetURLObject
+{
+public:
+    INetURLObject(int i);
+    int GetMainURL() const;
+};
+
+int foo(int infoo)             // { dg-warning "shadowed declaration" }
+{
+  int outfoo( INetURLObject( infoo ).GetMainURL()); // { dg-bogus "shadows" }
+  extern void f(int infoo);
+  struct A
+  {
+    void f(int infoo) { }      // { dg-warning "shadows a parameter" }
+  };
+  return outfoo;
+}