From: Nathan Sidwell Date: Thu, 23 Sep 2004 10:09:09 +0000 (+0000) Subject: re PR c++/17620 (Bogus error with duplicate base class breaks boost) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=98d6e9afea98c81a0cb3fa9e1d5622d474dd52e1;p=gcc.git re PR c++/17620 (Bogus error with duplicate base class breaks boost) cp: 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. From-SVN: r87938 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e91d4251d8d..2d22a5984a4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-09-23 Nathan Sidwell + + PR c++/17620 + * decl.c (xref_basetypes): Look through typedefs before checking + for duplicate base. + 2004-09-22 Nathan Sidwell * cp-tree.h (unemitted_tinfo_decls): Make a VEC(tree). diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 73f54d92809..30bfa8b6ef6 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cfe8e6914fa..9f90b343cc6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-09-23 Nathan Sidwell + + PR c++/17620 + * g++.dg/inherit/base2.C: New. + 2004-09-22 Eric Botcazou * 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 index 00000000000..5c7d812c760 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/base2.C @@ -0,0 +1,12 @@ +// Copyright (C) 2004 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 23 Sep 2004 + +// Origin: Wolfgang Bangerth +// Bug 17620. Bogus duplicate base error. + +struct S {}; + +typedef S B; + +struct D1 : B {}; +struct D2 : B {};