aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-07-25 08:52:32 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-07-25 08:52:32 +0000
commit90b1ca2f5203e8df93ff5ae83aeff062b08ab7f9 (patch)
tree506f3b416d130f1f45ee3008143a3a1bb2d2bded /gcc/cp
parenta368a2fabba4c10b491e03316dde72f41efea80b (diff)
downloadgcc-90b1ca2f5203e8df93ff5ae83aeff062b08ab7f9.zip
gcc-90b1ca2f5203e8df93ff5ae83aeff062b08ab7f9.tar.gz
gcc-90b1ca2f5203e8df93ff5ae83aeff062b08ab7f9.tar.bz2
class.c (build_vbase_offset_vbtl_entries): Look for non-primary base of which we are a sub vtable.
cp: * class.c (build_vbase_offset_vbtl_entries): Look for non-primary base of which we are a sub vtable. testsuite: * g++.old-deja/g++.abi/vbase8-5.C: New test. From-SVN: r44336
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/class.c28
2 files changed, 32 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8e10f73..08e91be 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2001-07-25 Nathan Sidwell <nathan@codesourcery.com>
+
+ * class.c (build_vbase_offset_vbtl_entries): Look for
+ non-primary base of which we are a sub vtable.
+
2001-07-24 Phil Edwards <pme@sources.redhat.com>
* semantics.c (finish_this_expr): Remove unused code.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index be04e89..f672954 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -7671,6 +7671,7 @@ build_vbase_offset_vtbl_entries (binfo, vid)
{
tree vbase;
tree t;
+ tree non_primary_binfo;
/* If there are no virtual baseclasses, then there is nothing to
do. */
@@ -7678,6 +7679,30 @@ build_vbase_offset_vtbl_entries (binfo, vid)
return;
t = vid->derived;
+
+ /* We might be a primary base class. Go up the inheritance hierarchy
+ until we find the most derived class of which we are a primary base:
+ it is the offset of that which we need to use. */
+ non_primary_binfo = binfo;
+ while (BINFO_INHERITANCE_CHAIN (non_primary_binfo))
+ {
+ tree b;
+
+ /* If we have reached a virtual base, then it must be a primary
+ base (possibly multi-level) of vid->binfo, or we wouldn't
+ have called build_vcall_and_vbase_vtbl_entries for it. But it
+ might be a lost primary, so just skip down to vid->binfo. */
+ if (TREE_VIA_VIRTUAL (non_primary_binfo))
+ {
+ non_primary_binfo = vid->binfo;
+ break;
+ }
+
+ b = BINFO_INHERITANCE_CHAIN (non_primary_binfo);
+ if (get_primary_binfo (b) != non_primary_binfo)
+ break;
+ non_primary_binfo = b;
+ }
/* Go through the virtual bases, adding the offsets. */
for (vbase = TYPE_BINFO (BINFO_TYPE (binfo));
@@ -7729,7 +7754,8 @@ build_vbase_offset_vtbl_entries (binfo, vid)
The vbase offsets go in reverse inheritance-graph order, and
we are walking in inheritance graph order so these end up in
the right order. */
- delta = size_diffop (BINFO_OFFSET (b), BINFO_OFFSET (binfo));
+ delta = size_diffop (BINFO_OFFSET (b), BINFO_OFFSET (non_primary_binfo));
+
*vid->last_init
= build_tree_list (NULL_TREE,
fold (build1 (NOP_EXPR,