+2000-06-14 Mark Mitchell <mark@codesourcery.com>
+
+ * 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 <jakub@redhat.com>
* class.c (build_secondary_vtable): Set DECL_USER_ALIGN.
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))
{
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
/* 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);
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.
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).
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)
\f