diff options
author | hp <hp@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-12-29 02:41:05 +0000 |
---|---|---|
committer | hp <hp@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-12-29 02:41:05 +0000 |
commit | 10ad6c9f34096cb72bf0895887cd272eecf815b9 (patch) | |
tree | daa61e406fe46535f96ed8ad813fbe1d1bb3b167 | |
parent | 92debfc20fc87ce5323addf9191844c2ebd94936 (diff) | |
download | gcc-10ad6c9f34096cb72bf0895887cd272eecf815b9.tar.gz |
* search.c (binfo_for_vtable): Return least derived class, not
most. Handle secondary vtables.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38521 138bc75d-0d04-0410-961f-82ee72b054a4
-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 6054868d0d8..92a8419ec76 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 2f4a3e94671..72f00901350 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 |