]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/14186 (enum in base class conflicts with derived class)
authorMark Mitchell <mark@codesourcery.com>
Fri, 20 Feb 2004 06:43:08 +0000 (06:43 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 20 Feb 2004 06:43:08 +0000 (06:43 +0000)
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

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

index e0cd7650aebee7eef8816fc40bd1d67f8e530aff..d1dea6dd76181f7fdcb8783d1479b1489c6d4b03 100644 (file)
@@ -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
index e1cc770dfe16badf6d0c573cc75bf9456bf6263b..e823ae3845842ac9f9bb4e9f6bcc57a113588359 100644 (file)
@@ -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
index 45acf23ec1690ac937b285e6b3035b08dcb2121a..9ead668c15e7cf17ed74f25f82c3d61422d4f59f 100644 (file)
@@ -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 (file)
index 0000000..82bb657
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/14186
+
+struct Base 
+{ 
+  enum { Derived }; 
+}; 
+class Derived : public Base 
+{ 
+  Derived(); 
+};