diff options
author | Mark Mitchell <mark@codesourcery.com> | 2004-02-20 06:43:08 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2004-02-20 06:43:08 +0000 |
commit | a6567a0faaeafd7dc37eb6d52666c12f466c376f (patch) | |
tree | 672b0866db4b5b381df2069fe9d95a9aeab85507 | |
parent | f819a6a516e88b987f72f374c5e5d5e8f3ec2798 (diff) | |
download | gcc-a6567a0faaeafd7dc37eb6d52666c12f466c376f.zip gcc-a6567a0faaeafd7dc37eb6d52666c12f466c376f.tar.gz gcc-a6567a0faaeafd7dc37eb6d52666c12f466c376f.tar.bz2 |
re PR c++/14186 (enum in base class conflicts with derived class)
PR c++/14186
* name-lookup.c (push_class_level_binding): Do not complain about
adding a binding for a member whose name is the same as the
enclosing class if the member is located in a base class of the
current class.
PR c++/14186
* g++.dg/lookup/member1.C: New test.
From-SVN: r78149
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/member1.C | 11 |
4 files changed, 31 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e0cd765..d1dea6d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2004-02-19 Mark Mitchell <mark@codesourcery.com> + + PR c++/14186 + * name-lookup.c (push_class_level_binding): Do not complain about + adding a binding for a member whose name is the same as the + enclosing class if the member is located in a base class of the + current class. + 2004-02-19 Giovanni Bajo <giovannibajo@gcc.gnu.org> PR c++/14181 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index e1cc770..e823ae3 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -2762,9 +2762,13 @@ push_class_level_binding (tree name, tree x) && DECL_CONTEXT (x) != current_class_type)) && DECL_NAME (x) == constructor_name (current_class_type)) { - error ("`%D' has the same name as the class in which it is declared", - x); - POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, false); + tree scope = context_for_name_lookup (x); + if (TYPE_P (scope) && same_type_p (scope, current_class_type)) + { + error ("`%D' has the same name as the class in which it is declared", + x); + POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, false); + } } /* If this declaration shadows a declaration from an enclosing diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 45acf23..9ead668c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-02-19 Mark Mitchell <mark@codesourcery.com> + + PR c++/14186 + * g++.dg/lookup/member1.C: New test. + 2004-02-19 Kazu Hirata <kazu@cs.umass.edu> * gcc.c-torture/compile/20040130-1.c: Enable only when diff --git a/gcc/testsuite/g++.dg/lookup/member1.C b/gcc/testsuite/g++.dg/lookup/member1.C new file mode 100644 index 0000000..82bb657 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/member1.C @@ -0,0 +1,11 @@ +// PR c++/14186 + +struct Base +{ + enum { Derived }; +}; + +class Derived : public Base +{ + Derived(); +}; |