diff options
author | Jason Merrill <jason@redhat.com> | 2009-04-14 13:04:04 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-04-14 13:04:04 -0400 |
commit | f9b20c620aac52350d4de6956878f791df10ba38 (patch) | |
tree | 76e3155ad284843c0ee3e67ab11f815fcc73029e /gcc | |
parent | 85d04fa2c85e47a17618b25da05a91344a053096 (diff) | |
download | gcc-f9b20c620aac52350d4de6956878f791df10ba38.zip gcc-f9b20c620aac52350d4de6956878f791df10ba38.tar.gz gcc-f9b20c620aac52350d4de6956878f791df10ba38.tar.bz2 |
re PR c++/39763 (-Wshadow reports shadowed declarations for parameters of unnamed temp objects)
PR c++/39763
* name-lookup.c (pushdecl_maybe_friend): Avoid all warnings
about shadowing by tentative parms.
From-SVN: r146053
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wshadow-4.C | 12 |
4 files changed, 35 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d7db865..e335f9e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2009-04-14 Jason Merrill <jason@redhat.com> + + PR c++/39763 + * name-lookup.c (pushdecl_maybe_friend): Avoid all warnings + about shadowing by tentative parms. + 2009-04-13 Jason Merrill <jason@redhat.com> PR c++/39480 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 2eebb79..b47c0c5 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1008,13 +1008,18 @@ pushdecl_maybe_friend (tree x, bool is_friend) && TREE_PUBLIC (x)) TREE_PUBLIC (name) = 1; + /* Don't complain about the parms we push and then pop + while tentatively parsing a function declarator. */ + if (TREE_CODE (x) == PARM_DECL && DECL_CONTEXT (x) == NULL_TREE) + /* Ignore. */; + /* Warn if shadowing an argument at the top level of the body. */ - if (oldlocal != NULL_TREE && !DECL_EXTERNAL (x) - /* Inline decls shadow nothing. */ - && !DECL_FROM_INLINE (x) - && TREE_CODE (oldlocal) == PARM_DECL - /* Don't check the `this' parameter. */ - && !DECL_ARTIFICIAL (oldlocal)) + else if (oldlocal != NULL_TREE && !DECL_EXTERNAL (x) + /* Inline decls shadow nothing. */ + && !DECL_FROM_INLINE (x) + && TREE_CODE (oldlocal) == PARM_DECL + /* Don't check the `this' parameter. */ + && !DECL_ARTIFICIAL (oldlocal)) { bool err = false; @@ -1038,10 +1043,7 @@ pushdecl_maybe_friend (tree x, bool is_friend) } } - 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)) + if (warn_shadow && !err) { warning (OPT_Wshadow, "declaration of %q#D shadows a parameter", x); warning (OPT_Wshadow, "%Jshadowed declaration is here", oldlocal); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d3405be..d0473e7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-04-14 Jason Merrill <jason@redhat.com> + + PR c++/39763 + * g++.dg/warn/Wshadow-4.C: Extend. + 2009-04-14 Uros Bizjak <ubizjak@gmail.com> * gcc.target/alpha/pr39740.c (dg-options): Add -mexplicit-relocs. diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-4.C b/gcc/testsuite/g++.dg/warn/Wshadow-4.C index 16399b2..2238653 100644 --- a/gcc/testsuite/g++.dg/warn/Wshadow-4.C +++ b/gcc/testsuite/g++.dg/warn/Wshadow-4.C @@ -18,3 +18,15 @@ int foo(int infoo) // { dg-warning "shadowed declaration" } }; return outfoo; } + +// PR c++/39763 +int foo2(void) +{ + int infoo = 0; // { dg-warning "shadowed declaration" } + int outfoo( INetURLObject( infoo ).GetMainURL()); // { dg-bogus "shadows" } + struct A + { + void f(int infoo) { } // { dg-warning "shadows a previous local" } + }; + return outfoo; +} |