diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-06-19 14:13:58 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-06-19 14:13:58 +0000 |
commit | c14c0b1568f84e974152d2e2c1bc3da384a16f2d (patch) | |
tree | 57553ed133097cb2871583923f1bdbdb7fbe84d2 /gcc | |
parent | a6e5212a77e34682cfb591ed80e7166eaa895365 (diff) | |
download | gcc-c14c0b1568f84e974152d2e2c1bc3da384a16f2d.zip gcc-c14c0b1568f84e974152d2e2c1bc3da384a16f2d.tar.gz gcc-c14c0b1568f84e974152d2e2c1bc3da384a16f2d.tar.bz2 |
re PR c++/81119 (-Wshadow warns on "typedef struct foo foo;")
PR c++/81119
* name-lookup.c (update_binding): Only warn about constructors
hidden by functions.
PR c++/81119
* g++.dg/warn/pr81119.C: New.
From-SVN: r249369
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/pr81119.C | 20 |
4 files changed, 39 insertions, 15 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 465e7d9..fece2d0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-06-19 Nathan Sidwell <nathan@acm.org> + + PR c++/81119 + * name-lookup.c (update_binding): Only warn about constructors + hidden by functions. + 2017-06-17 Jason Merrill <jason@redhat.com> PR c++/60063 - -Wunused-local-typedefs and templates. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 6ed164d..a337942 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1784,6 +1784,14 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot, else goto conflict; + if (to_type != old_type + && warn_shadow + && MAYBE_CLASS_TYPE_P (TREE_TYPE (to_type)) + && !(DECL_IN_SYSTEM_HEADER (decl) + && DECL_IN_SYSTEM_HEADER (to_type))) + warning (OPT_Wshadow, "%q#D hides constructor for %q#D", + decl, to_type); + to_val = ovl_insert (decl, old); } else if (!old) @@ -1849,21 +1857,6 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot, add_decl_to_level (level, to_add); } - if (to_type != old_type) - { - gcc_checking_assert (!old_type - && TREE_CODE (to_type) == TYPE_DECL - && DECL_ARTIFICIAL (to_type)); - - tree type = TREE_TYPE (to_type); - if (to_type != decl - && MAYBE_CLASS_TYPE_P (type) && warn_shadow - && (!DECL_IN_SYSTEM_HEADER (decl) - || !DECL_IN_SYSTEM_HEADER (to_type))) - warning (OPT_Wshadow, "%q#D hides constructor for %q#T", - decl, type); - } - if (slot) { if (STAT_HACK_P (*slot)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 26e527c..c7729e8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-06-19 Nathan Sidwell <nathan@acm.org> + + PR c++/81119 + * g++.dg/warn/pr81119.C: New. + 2017-06-19 Martin Liska <mliska@suse.cz> PR sanitizer/80879 diff --git a/gcc/testsuite/g++.dg/warn/pr81119.C b/gcc/testsuite/g++.dg/warn/pr81119.C new file mode 100644 index 0000000..2f82236 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr81119.C @@ -0,0 +1,20 @@ +// PR c++/81119 Wshadow regression +// { dg-additional-options "-Wshadow" } + +struct A; +typedef A A; // No warning, does not hide + +struct B; // { dg-message "previous" } +typedef int B; // { dg-error "conflicting" } + +struct C; +void C (); // { dg-warning "hides constructor" } +void C (int); // warning not repeated + +struct D; +int D; // no warning, not a function + +struct E; + +enum X + {E}; // no warning, not a function |