diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2001-07-27 15:12:49 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2001-07-27 15:12:49 +0000 |
commit | 0ab142b0273f6b8f76386e524702c969b7609afe (patch) | |
tree | 9a1ca077f80ae1edb19df119baaea738f59a70d6 /gcc/cp/class.c | |
parent | d60d223b176c68cf2559eed8244977f935b39be9 (diff) | |
download | gcc-0ab142b0273f6b8f76386e524702c969b7609afe.tar.gz |
class.c (mark_primary_virtual_base): Don't adjust base offsets here.
cp:
* class.c (mark_primary_virtual_base): Don't adjust base
offsets here.
(dfs_unshared_virtual_bases): Adjust them here.
(mark_primary_bases): Explain why we adjust at the end.
testsuite:
* g++.dg/abi/vbase8-21.C: New test.
From-SVN: r44425
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 18ade132d17..7f2ea601775 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1523,7 +1523,6 @@ mark_primary_virtual_base (binfo, base_binfo, type) tree type; { tree shared_binfo = binfo_for_vbase (BINFO_TYPE (base_binfo), type); - tree delta; if (BINFO_PRIMARY_P (shared_binfo)) { @@ -1542,12 +1541,6 @@ mark_primary_virtual_base (binfo, base_binfo, type) if (base_binfo != shared_binfo) force_canonical_binfo (base_binfo, shared_binfo, type, NULL); - delta = size_diffop (BINFO_OFFSET (binfo), BINFO_OFFSET (base_binfo)); - if (!integer_zerop (delta)) - { - propagate_binfo_offsets (base_binfo, delta, type); - BINFO_OFFSET (base_binfo) = BINFO_OFFSET (binfo); - } return base_binfo; } @@ -1580,7 +1573,7 @@ static tree dfs_unshared_virtual_bases (binfo, data) my_friendly_assert (unshared_base != binfo, 20010612); BINFO_LOST_PRIMARY_P (binfo) = BINFO_LOST_PRIMARY_P (unshared_base); if (!BINFO_LOST_PRIMARY_P (binfo)) - BINFO_PRIMARY_BASE_OF (get_primary_binfo (binfo)) = binfo; + BINFO_PRIMARY_BASE_OF (get_primary_binfo (binfo)) = binfo; } if (binfo != TYPE_BINFO (t)) @@ -1588,6 +1581,17 @@ static tree dfs_unshared_virtual_bases (binfo, data) base binfos. That information is bogus, make sure we don't try and use it. */ BINFO_VTABLE (binfo) = NULL_TREE; + + /* If this is a virtual primary base, make sure its offset matches + that which it is primary for. */ + if (BINFO_PRIMARY_P (binfo) && TREE_VIA_VIRTUAL (binfo) && + binfo_for_vbase (BINFO_TYPE (binfo), t) == binfo) + { + tree delta = size_diffop (BINFO_OFFSET (BINFO_PRIMARY_BASE_OF (binfo)), + BINFO_OFFSET (binfo)); + if (!integer_zerop (delta)) + propagate_binfo_offsets (binfo, delta, t); + } BINFO_UNSHARED_MARKED (binfo) = 0; return NULL; @@ -1621,9 +1625,14 @@ mark_primary_bases (type) BINFO_UNSHARED_MARKED (binfo) = 1; } - /* There could remain unshared morally virtual bases which were not visited - in the inheritance graph walk. These bases will have lost their - virtual primary base (should they have one). We must now find them. */ + /* There could remain unshared morally virtual bases which were not + visited in the inheritance graph walk. These bases will have lost + their virtual primary base (should they have one). We must now + find them. Also we must fix up the BINFO_OFFSETs of primary + virtual bases. We could not do that as we went along, as they + were originally copied from the bases we inherited from by + unshare_base_binfos. That may have decided differently about + where a virtual primary base went. */ dfs_walk (TYPE_BINFO (type), dfs_unshared_virtual_bases, NULL, type); } |