diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2001-09-06 09:03:31 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2001-09-06 09:03:31 +0000 |
commit | 39e78d8bfc3694572557af874479c96ee259b067 (patch) | |
tree | df62c41b750800eafdffc224e0cddd50bb212ab3 | |
parent | 6d0a3f67bb68552229f14f90dd42254de5d17016 (diff) | |
download | gcc-39e78d8bfc3694572557af874479c96ee259b067.zip gcc-39e78d8bfc3694572557af874479c96ee259b067.tar.gz gcc-39e78d8bfc3694572557af874479c96ee259b067.tar.bz2 |
re PR c++/3986 (ICE in build_rtti_vtbl_entries)
cp:
PR c++/3986
* class.c (force_canonical_binfo_r): Check & move an indirect
primary base first.
(force_canonical_binfo): Check that it's not already
canonical.
(mark_primary_virtual_base): Remove BINFO parameter.
(mark_primary_bases): Adjust, set BINFO_LOST_PRIMARY_P here.
testsuite:
PR c++/3986
* g++.dg/abi/vbase1.C: New test.
From-SVN: r45435
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/class.c | 36 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/abi/vbase1.C | 60 |
4 files changed, 100 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index be43b1f..9562779 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,15 @@ 2001-09-06 Nathan Sidwell <nathan@codesourcery.com> + PR c++/3986 + * class.c (force_canonical_binfo_r): Check & move an indirect + primary base first. + (force_canonical_binfo): Check that it's not already + canonical. + (mark_primary_virtual_base): Remove BINFO parameter. + (mark_primary_bases): Adjust, set BINFO_LOST_PRIMARY_P here. + +2001-09-06 Nathan Sidwell <nathan@codesourcery.com> + Remove TYPE_NONCOPIED_PARTS. * cp-tree.h (CLASSTYPE_INLINE_FRIENDS): Map onto CLASSTYPE_PURE_VIRTUALS. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 03aa7f7..78659c7 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1437,7 +1437,8 @@ force_canonical_binfo_r (to, from, type, mappings) tree mappings; { int i, n_baseclasses = BINFO_N_BASETYPES (from); - + + my_friendly_assert (to != from, 20010905); BINFO_INDIRECT_PRIMARY_P (to) = BINFO_INDIRECT_PRIMARY_P (from); BINFO_INDIRECT_PRIMARY_P (from) = 0; @@ -1461,11 +1462,22 @@ force_canonical_binfo_r (to, from, type, mappings) my_friendly_assert (same_type_p (BINFO_TYPE (to), BINFO_TYPE (from)), 20010104); mappings = tree_cons (from, to, mappings); + + if (CLASSTYPE_HAS_PRIMARY_BASE_P (BINFO_TYPE (from)) + && TREE_VIA_VIRTUAL (CLASSTYPE_PRIMARY_BINFO (BINFO_TYPE (from)))) + { + tree from_primary = get_primary_binfo (from); + + if (BINFO_PRIMARY_BASE_OF (from_primary) == from) + force_canonical_binfo (get_primary_binfo (to), from_primary, + type, mappings); + } + for (i = 0; i != n_baseclasses; i++) { tree from_binfo = BINFO_BASETYPE (from, i); tree to_binfo = BINFO_BASETYPE (to, i); - + if (TREE_VIA_VIRTUAL (from_binfo)) { if (BINFO_PRIMARY_P (from_binfo) && @@ -1498,17 +1510,19 @@ force_canonical_binfo (to, from, type, mappings) { tree assoc = purpose_member (BINFO_TYPE (to), CLASSTYPE_VBASECLASSES (type)); - TREE_VALUE (assoc) = to; - force_canonical_binfo_r (to, from, type, mappings); + if (TREE_VALUE (assoc) != to) + { + TREE_VALUE (assoc) = to; + force_canonical_binfo_r (to, from, type, mappings); + } } -/* Make BASE_BINFO the primary virtual base of BINFO within the hierarchy - dominated by TYPE. Returns BASE_BINFO, if it can be made so, NULL +/* Make BASE_BINFO the a primary virtual base within the hierarchy + dominated by TYPE. Returns BASE_BINFO, if it is not already one, NULL otherwise (because something else has already made it primary). */ static tree -mark_primary_virtual_base (binfo, base_binfo, type) - tree binfo; +mark_primary_virtual_base (base_binfo, type) tree base_binfo; tree type; { @@ -1519,8 +1533,6 @@ mark_primary_virtual_base (binfo, base_binfo, type) /* It's already allocated in the hierarchy. BINFO won't have a primary base in this hierachy, even though the complete object BINFO is for, would do. */ - BINFO_LOST_PRIMARY_P (binfo) = 1; - return NULL_TREE; } @@ -1608,10 +1620,12 @@ mark_primary_bases (type) base_binfo = get_primary_binfo (binfo); if (TREE_VIA_VIRTUAL (base_binfo)) - base_binfo = mark_primary_virtual_base (binfo, base_binfo, type); + base_binfo = mark_primary_virtual_base (base_binfo, type); if (base_binfo) BINFO_PRIMARY_BASE_OF (base_binfo) = binfo; + else + BINFO_LOST_PRIMARY_P (binfo) = 1; BINFO_UNSHARED_MARKED (binfo) = 1; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0b5516c..8592eeb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2001-09-06 Nathan Sidwell <nathan@codesourcery.com> + + PR c++/3986 + * g++.dg/abi/vbase1.C: New test. + 2001-09-05 Ziemowit Laski <zlaski@apple.com> * objc.dg/method-2.m: New. diff --git a/gcc/testsuite/g++.dg/abi/vbase1.C b/gcc/testsuite/g++.dg/abi/vbase1.C new file mode 100644 index 0000000..39d8b81 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/vbase1.C @@ -0,0 +1,60 @@ +// { dg-do compile } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Sept 2001 <nathan@codesourcery.com> + +// Bug 3986. Another indirect primary base problem. + +struct Consts +{ +}; + +struct MathLib : + virtual Consts +{ +}; + +struct Parallel : + virtual Consts +{ +}; + +struct Particles : + virtual MathLib, + virtual Parallel +{ +}; + +struct Ring : + virtual Particles +{ +}; + +struct Injection : + virtual Particles, + virtual Ring +{ +}; + +struct LSpaceCharge : + virtual Ring, + virtual Injection +{ +}; + +struct Bump : + virtual Consts +{ +}; + +struct Output : + virtual Injection, + virtual Bump +{ +}; + +struct Plots : + virtual LSpaceCharge, + virtual Output +{ +}; |