diff options
author | Hans-Peter Nilsson <hp@bitrange.com> | 2000-12-29 02:41:05 +0000 |
---|---|---|
committer | Hans-Peter Nilsson <hp@gcc.gnu.org> | 2000-12-29 02:41:05 +0000 |
commit | 6f18f7e9b73bb769ad3b2bf35cea7f20bd09f99e (patch) | |
tree | daa61e406fe46535f96ed8ad813fbe1d1bb3b167 | |
parent | 328a8516f5a6cdf253e2285659e428c7c2ad9600 (diff) | |
download | gcc-6f18f7e9b73bb769ad3b2bf35cea7f20bd09f99e.zip gcc-6f18f7e9b73bb769ad3b2bf35cea7f20bd09f99e.tar.gz gcc-6f18f7e9b73bb769ad3b2bf35cea7f20bd09f99e.tar.bz2 |
search.c (binfo_for_vtable): Return least derived class, not most.
* search.c (binfo_for_vtable): Return least derived class, not
most. Handle secondary vtables.
From-SVN: r38521
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/search.c | 25 |
2 files changed, 24 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6054868..92a8419 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-12-29 Hans-Peter Nilsson <hp@bitrange.com> + + * search.c (binfo_for_vtable): Return least derived class, not + most. Handle secondary vtables. + 2000-12-22 Jason Merrill <jason@redhat.com> * typeck.c (build_binary_op): Fix pmf comparison logic. diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 2f4a3e9..72f0090 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -3250,20 +3250,33 @@ types_overlap_p (empty_type, next_type) return oi.found_overlap; } -/* Given a vtable VAR, determine which binfo it comes from. +/* Given a vtable VAR, determine which of the inherited classes the vtable + inherits (in a loose sense) functions from. - FIXME What about secondary vtables? */ + FIXME: This does not work with the new ABI. */ tree binfo_for_vtable (var) tree var; { - tree binfo = TYPE_BINFO (DECL_CONTEXT (var)); + tree main_binfo = TYPE_BINFO (DECL_CONTEXT (var)); + tree binfos = TYPE_BINFO_BASETYPES (BINFO_TYPE (main_binfo)); + int n_baseclasses = CLASSTYPE_N_BASECLASSES (BINFO_TYPE (main_binfo)); + int i; + + for (i = 0; i < n_baseclasses; i++) + { + tree base_binfo = TREE_VEC_ELT (binfos, i); + if (base_binfo != NULL_TREE && BINFO_VTABLE (base_binfo) == var) + return base_binfo; + } - while (CLASSTYPE_HAS_PRIMARY_BASE_P (BINFO_TYPE (binfo))) - binfo = get_primary_binfo (binfo); + /* If no secondary base classes matched, return the primary base, if + there is one. */ + if (CLASSTYPE_HAS_PRIMARY_BASE_P (BINFO_TYPE (main_binfo))) + return get_primary_binfo (main_binfo); - return binfo; + return main_binfo; } /* Returns the binfo of the first direct or indirect virtual base from |