re PR c++/39526 (-Wshadow reports shadowed declarations for parameters of unnamed temp objects)

PR c++/39526
        * name-lookup.c (pushdecl_maybe_friend): Don't warn about shadowing
        a parm with a parm.

From-SVN: r145012
This commit is contained in:
Jason Merrill 2009-03-23 16:32:53 -04:00 committed by Jason Merrill
parent 3691626c34
commit 6ab282f650
4 changed files with 35 additions and 1 deletions

View 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

View 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);

View 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

View File

@ -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;
}