From: Mark Mitchell Date: Wed, 14 Jun 2000 16:10:14 +0000 (+0000) Subject: cp-tree.h (BINFO_OVERRIDE_ALONG_VIRTUAL_PATH): New macro. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db3d8cded1c77bed802062a6cea77f47055206af;p=platform%2Fupstream%2Fgcc.git cp-tree.h (BINFO_OVERRIDE_ALONG_VIRTUAL_PATH): New macro. * cp-tree.h (BINFO_OVERRIDE_ALONG_VIRTUAL_PATH): New macro. * class.c (dfs_find_final_overrider): Set it appropriately. (dfs_built_vtt_inits): Check BINFO_OVERRIDE_ALONG_VIRTUAL_PATH to avoid unneeded secondary vptrs. From-SVN: r34549 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ff78949..1cf4879 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2000-06-14 Mark Mitchell + + * cp-tree.h (BINFO_OVERRIDE_ALONG_VIRTUAL_PATH): New macro. + * class.c (dfs_find_final_overrider): Set it appropriately. + (dfs_built_vtt_inits): Check BINFO_OVERRIDE_ALONG_VIRTUAL_PATH to + avoid unneeded secondary vptrs. + 2000-06-13 Jakub Jelinek * class.c (build_secondary_vtable): Set DECL_USER_ALIGN. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 5d8390f..33f12b5 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2453,9 +2453,11 @@ dfs_find_final_overrider (binfo, data) tree path; tree method; + /* We haven't found an overrider yet. */ + method = NULL_TREE; /* We've found a path to the declaring base. Walk down the path looking for an overrider for FN. */ - for (path = reverse_path (binfo); + for (path = reverse_path (binfo); path; path = TREE_CHAIN (path)) { @@ -2474,6 +2476,24 @@ dfs_find_final_overrider (binfo, data) the base from which it came. */ if (path) { + tree base; + + /* Assume the path is non-virtual. See if there are any base from + (but not including) the overrider up to and including the + base where the function is defined. */ + for (base = TREE_CHAIN (path); base; base = TREE_CHAIN (base)) + if (TREE_VIA_VIRTUAL (TREE_VALUE (base))) + { + base = ffod->declaring_base; + while (BINFO_PRIMARY_MARKED_P (base)) + { + BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P (base) = 1; + base = BINFO_INHERITANCE_CHAIN (base); + } + BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P (base) = 1; + break; + } + if (ffod->overriding_fn && ffod->overriding_fn != method) { /* We've found a different overrider along a different @@ -6729,10 +6749,19 @@ dfs_build_vtt_inits (binfo, data) /* If BINFO doesn't have virtual bases, then we have to look to see whether or not any virtual functions were overidden along a - virtual path between the declaration and T. */ - if (!TYPE_USES_VIRTUAL_BASECLASSES (BINFO_TYPE (binfo))) - /* FIXME: Implement this. */ - ; + virtual path. The point is that given: + + struct V { virtual void f(); int i; }; + struct C : public V { void f (); }; + + when we constrct C we need a secondary vptr for V-in-C because we + don't know what the vcall offset for `f' should be. If `V' ends + up in a different place in the complete object, then we'll need a + different vcall offset than that present in the normal V-in-C + vtable. */ + if (!TYPE_USES_VIRTUAL_BASECLASSES (BINFO_TYPE (binfo)) + && !BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P (binfo)) + return NULL_TREE; /* Record the index where this secondary vptr can be found. */ index = TREE_TYPE (l); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8fd8115..9418b2aa 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -55,11 +55,13 @@ Boston, MA 02111-1307, USA. */ BASELINK_P (in TREE_LIST) ICS_ELLIPSIS_FLAG (in _CONV) STMT_IS_FULL_EXPR_P (in _STMT) + BINFO_ACCESS (in BINFO) 2: IDENTIFIER_OPNAME_P. TYPE_POLYMORHPIC_P (in _TYPE) ICS_THIS_FLAG (in _CONV) STMT_LINENO_FOR_FN_P (in _STMT) BINDING_HAS_LEVEL_P (in CPLUS_BINDING) + BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P (in BINFO) 3: TYPE_USES_VIRTUAL_BASECLASSES (in a class TYPE). BINFO_VTABLE_PATH_MARKED. BINFO_PUSHDECLS_MARKED. @@ -76,6 +78,7 @@ Boston, MA 02111-1307, USA. */ IDENTIFIER_TYPENAME_P (in IDENTIFIER_NODE) 5: BINFO_PRIMARY_MARKED_P (in BINFO) 6: BINFO_VBASE_PRIMARY_P (in BINFO) + BINFO_ACCESS (in BINFO) Usage of TYPE_LANG_FLAG_?: 0: C_TYPE_FIELDS_READONLY (in RECORD_TYPE or UNION_TYPE). @@ -1784,6 +1787,10 @@ struct lang_type found. NULL_TREE if there is no secondary vptr in the VTT. */ #define BINFO_VPTR_INDEX(NODE) TREE_VEC_ELT ((NODE), 9) +/* Nonzero if this binfo declares a virtual function which is + overridden along a virtual path. */ +#define BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P(NODE) TREE_LANG_FLAG_2 (NODE) + /* Used by various search routines. */ #define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE)