OSDN Git Service

cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Sep 2004 10:09:09 +0000 (10:09 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Sep 2004 10:09:09 +0000 (10:09 +0000)
PR c++/17620
* decl.c (xref_basetypes): Look through typedefs before checking
for duplicate base.
testsuite:
PR c++/17620
* g++.dg/inherit/base2.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87938 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/inherit/base2.C [new file with mode: 0644]

index e91d425..2d22a59 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-23  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/17620
+       * decl.c (xref_basetypes): Look through typedefs before checking
+       for duplicate base.
+
 2004-09-22  Nathan Sidwell  <nathan@codesourcery.com>
 
        * cp-tree.h (unemitted_tinfo_decls): Make a VEC(tree).
index 73f54d9..30bfa8b 100644 (file)
@@ -9286,16 +9286,6 @@ xref_basetypes (tree ref, tree base_list)
          continue;
        }
 
-      if (TYPE_MARKED_P (basetype))
-       {
-         if (basetype == ref)
-           error ("recursive type `%T' undefined", basetype);
-         else
-           error ("duplicate base type `%T' invalid", basetype);
-         continue;
-       }
-      TYPE_MARKED_P (basetype) = 1;
-
       if (TYPE_FOR_JAVA (basetype) && (current_lang_depth () == 0))
        TYPE_FOR_JAVA (ref) = 1;
 
@@ -9318,6 +9308,18 @@ xref_basetypes (tree ref, tree base_list)
          CLASSTYPE_REPEATED_BASE_P (ref)
            |= CLASSTYPE_REPEATED_BASE_P (basetype);
        }
+      
+      /* We must do this test after we've seen through a typedef
+        type.  */
+      if (TYPE_MARKED_P (basetype))
+       {
+         if (basetype == ref)
+           error ("recursive type `%T' undefined", basetype);
+         else
+           error ("duplicate base type `%T' invalid", basetype);
+         continue;
+       }
+      TYPE_MARKED_P (basetype) = 1;
 
       base_binfo = copy_binfo (base_binfo, basetype, ref,
                               &igo_prev, via_virtual);
index cfe8e69..9f90b34 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-23  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/17620
+       * g++.dg/inherit/base2.C: New.
+
 2004-09-22  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/20001012-1.c: Add prototypes for builtin functions.
diff --git a/gcc/testsuite/g++.dg/inherit/base2.C b/gcc/testsuite/g++.dg/inherit/base2.C
new file mode 100644 (file)
index 0000000..5c7d812
--- /dev/null
@@ -0,0 +1,12 @@
+// Copyright (C) 2004 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 23 Sep 2004 <nathan@codesourcery.com>
+
+// Origin: Wolfgang Bangerth <bangerth@dealii.org>
+// Bug 17620. Bogus duplicate base error.
+
+struct S {}; 
+typedef S B; 
+struct D1 : B {}; 
+struct D2 : B {};