From: Hans-Peter Nilsson Date: Fri, 29 Dec 2000 02:41:05 +0000 (+0000) Subject: search.c (binfo_for_vtable): Return least derived class, not most. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6f18f7e9b73bb769ad3b2bf35cea7f20bd09f99e;p=gcc.git 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 --- 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 + + * search.c (binfo_for_vtable): Return least derived class, not + most. Handle secondary vtables. + 2000-12-22 Jason Merrill * 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