static void handle_using_decl PARAMS ((tree, tree));
static void check_for_override PARAMS ((tree, tree));
static tree dfs_modify_vtables PARAMS ((tree, void *));
-static tree modify_all_vtables PARAMS ((tree, int *, tree));
-static void determine_primary_base PARAMS ((tree, int *));
+static tree modify_all_vtables PARAMS ((tree, tree));
+static void determine_primary_base PARAMS ((tree));
static void finish_struct_methods PARAMS ((tree));
static void maybe_warn_about_overly_private_class PARAMS ((tree));
static int field_decl_cmp PARAMS ((const tree *, const tree *));
static void check_bases_and_members (tree);
static tree create_vtable_ptr (tree, tree *);
static void include_empty_classes (record_layout_info);
-static void layout_class_type (tree, int *, tree *);
+static void layout_class_type (tree, tree *);
static void fixup_pending_inline PARAMS ((tree));
static void fixup_inline_methods PARAMS ((tree));
-static void set_primary_base PARAMS ((tree, tree, int *));
+static void set_primary_base PARAMS ((tree, tree));
static void propagate_binfo_offsets PARAMS ((tree, tree, tree));
static void layout_virtual_bases (record_layout_info, splay_tree);
static tree dfs_set_offset_for_unshared_vbases PARAMS ((tree, void *));
static void accumulate_vtbl_inits PARAMS ((tree, tree, tree, tree, tree));
static tree dfs_accumulate_vtbl_inits PARAMS ((tree, tree, tree, tree,
tree));
-static void set_vindex PARAMS ((tree, int *));
static void build_rtti_vtbl_entries PARAMS ((tree, vtbl_init_data *));
static void build_vcall_and_vbase_vtbl_entries PARAMS ((tree,
vtbl_init_data *));
BV_DELTA (v) = delta;
BV_VCALL_INDEX (v) = NULL_TREE;
BV_FN (v) = fndecl;
-
- /* Now assign virtual dispatch information, if unset. We can
- dispatch this through any overridden base function.
-
- FIXME this can choose a secondary vtable if the primary is not
- also lexically first, leading to useless conversions.
- In the V3 ABI, there's no reason for DECL_VIRTUAL_CONTEXT to
- ever be different from DECL_CONTEXT. */
- if (TREE_CODE (DECL_VINDEX (fndecl)) != INTEGER_CST)
- {
- DECL_VINDEX (fndecl) = DECL_VINDEX (base_fndecl);
- DECL_VIRTUAL_CONTEXT (fndecl) = DECL_VIRTUAL_CONTEXT (base_fndecl);
- }
}
}
-/* Set DECL_VINDEX for DECL. VINDEX_P is the number of virtual
- functions present in the vtable so far. */
-
-static void
-set_vindex (decl, vfuns_p)
- tree decl;
- int *vfuns_p;
-{
- int vindex;
-
- vindex = *vfuns_p;
- *vfuns_p += (TARGET_VTABLE_USES_DESCRIPTORS
- ? TARGET_VTABLE_USES_DESCRIPTORS : 1);
- DECL_VINDEX (decl) = build_shared_int_cst (vindex);
-}
\f
/* Add method METHOD to class TYPE. If ERROR_P is true, we are adding
the method after the class has already been defined because a
/* Make the BINFO the primary base of T. */
static void
-set_primary_base (t, binfo, vfuns_p)
+set_primary_base (t, binfo)
tree t;
tree binfo;
- int *vfuns_p;
{
tree basetype;
TYPE_BINFO_VIRTUALS (t) = TYPE_BINFO_VIRTUALS (basetype);
TYPE_VFIELD (t) = TYPE_VFIELD (basetype);
CLASSTYPE_RTTI (t) = CLASSTYPE_RTTI (basetype);
- *vfuns_p = CLASSTYPE_VSIZE (basetype);
}
/* Determine the primary class for T. */
static void
-determine_primary_base (t, vfuns_p)
+determine_primary_base (t)
tree t;
- int *vfuns_p;
{
int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (t);
tree vbases;
if (!CLASSTYPE_HAS_PRIMARY_BASE_P (t))
{
- set_primary_base (t, base_binfo, vfuns_p);
+ set_primary_base (t, base_binfo);
CLASSTYPE_VFIELDS (t) = copy_list (CLASSTYPE_VFIELDS (basetype));
}
else
/* If we've got a primary base, use it. */
if (candidate)
{
- set_primary_base (t, candidate, vfuns_p);
+ set_primary_base (t, candidate);
CLASSTYPE_VFIELDS (t)
= copy_list (CLASSTYPE_VFIELDS (BINFO_TYPE (candidate)));
}
should therefore be appended to the end of the vtable for T. */
static tree
-modify_all_vtables (t, vfuns_p, virtuals)
+modify_all_vtables (t, virtuals)
tree t;
- int *vfuns_p;
tree virtuals;
{
tree binfo = TYPE_BINFO (t);
if (!value_member (fn, BINFO_VIRTUALS (binfo))
|| DECL_VINDEX (fn) == error_mark_node)
{
- /* Set the vtable index. */
- set_vindex (fn, vfuns_p);
- /* We don't need to convert to a base class when calling
- this function. */
- DECL_VIRTUAL_CONTEXT (fn) = t;
-
/* We don't need to adjust the `this' pointer when
calling this function. */
BV_DELTA (*fnsp) = integer_zero_node;
/* We've already got an entry for this function. Skip it. */
*fnsp = TREE_CHAIN (*fnsp);
}
-
+
return virtuals;
}
pointer. Accumulate declared virtual functions on VIRTUALS_P. */
static void
-layout_class_type (tree t, int *vfuns_p, tree *virtuals_p)
+layout_class_type (tree t, tree *virtuals_p)
{
tree non_static_data_members;
tree field;
/* If possible, we reuse the virtual function table pointer from one
of our base classes. */
- determine_primary_base (t, vfuns_p);
+ determine_primary_base (t);
/* Create a pointer to our virtual function table. */
vptr = create_vtable_ptr (t, virtuals_p);
tree t;
{
tree x;
- int vfuns;
/* A TREE_LIST. The TREE_VALUE of each node is a FUNCTION_DECL. */
tree virtuals = NULL_TREE;
int n_fields = 0;
TYPE_SIZE (t) = NULL_TREE;
CLASSTYPE_GOT_SEMICOLON (t) = 0;
CLASSTYPE_PRIMARY_BINFO (t) = NULL_TREE;
- vfuns = 0;
CLASSTYPE_RTTI (t) = NULL_TREE;
fixup_inline_methods (t);
check_bases_and_members (t);
/* Layout the class itself. */
- layout_class_type (t, &vfuns, &virtuals);
+ layout_class_type (t, &virtuals);
/* Make sure that we get our own copy of the vfield FIELD_DECL. */
vfield = TYPE_VFIELD (t);
else
my_friendly_assert (!vfield || DECL_FIELD_CONTEXT (vfield) == t, 20010726);
- virtuals = modify_all_vtables (t, &vfuns, nreverse (virtuals));
+ virtuals = modify_all_vtables (t, nreverse (virtuals));
/* If we created a new vtbl pointer for this class, add it to the
list. */
if (TYPE_CONTAINS_VPTR_P (t))
{
+ int vindex;
+ tree fn;
+
if (TYPE_BINFO_VTABLE (t))
my_friendly_assert (DECL_VIRTUAL_P (TYPE_BINFO_VTABLE (t)),
20000116);
my_friendly_assert (TYPE_BINFO_VIRTUALS (t) == NULL_TREE,
20000116);
- CLASSTYPE_VSIZE (t) = vfuns;
/* Add entries for virtual functions introduced by this class. */
TYPE_BINFO_VIRTUALS (t) = chainon (TYPE_BINFO_VIRTUALS (t), virtuals);
+
+ /* Set DECL_VINDEX for all functions declared in this class. */
+ for (vindex = 0, fn = BINFO_VIRTUALS (TYPE_BINFO (t));
+ fn;
+ fn = TREE_CHAIN (fn),
+ vindex += (TARGET_VTABLE_USES_DESCRIPTORS
+ ? TARGET_VTABLE_USES_DESCRIPTORS : 1))
+ if (TREE_CODE (DECL_VINDEX (BV_FN (fn))) != INTEGER_CST)
+ DECL_VINDEX (BV_FN (fn)) = build_shared_int_cst (vindex);
}
finish_struct_bits (t);
remove a flag. */
unsigned dummy : 4;
- int vsize;
-
tree primary_base;
tree vfields;
tree vbases;
#define CLASSTYPE_PRIMARY_BINFO(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->primary_base)
-/* The number of virtual functions present in this class' virtual
- function table. */
-#define CLASSTYPE_VSIZE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vsize)
-
/* A chain of BINFOs for the direct and indirect virtual base classes
that this type uses in a post-order depth-first left-to-right
order. (In other words, these bases appear in the order that they
{
tree befriending_classes;
- /* For a virtual FUNCTION_DECL, this is DECL_VIRTUAL_CONTEXT. For a
- non-virtual FUNCTION_DECL, this is DECL_FRIEND_CONTEXT. */
+ /* For a non-virtual FUNCTION_DECL, this is
+ DECL_FRIEND_CONTEXT. For a virtual FUNCTION_DECL for which
+ DECL_THUNK_P does not hold, this is DECL_THUNKS. */
tree context;
-
- /* In a FUNCTION_DECL for which DECL_THUNK_P does not hold, this
- is DECL_THUNKS. */
- tree thunks;
/* In a FUNCTION_DECL, this is DECL_CLONED_FUNCTION. */
tree cloned_function;
/* The thunks associated with NODE, a FUNCTION_DECL that is not itself
a thunk. */
#define DECL_THUNKS(NODE) \
- (DECL_LANG_SPECIFIC (NODE)->u.f.thunks)
+ (DECL_LANG_SPECIFIC (NODE)->u.f.context)
/* Nonzero if NODE is a thunk, rather than an ordinary function. */
#define DECL_THUNK_P(NODE) \
(DECL_CONTEXT (NODE) ? DECL_CONTEXT (NODE) : global_namespace)
#define FROB_CONTEXT(NODE) ((NODE) == global_namespace ? NULL_TREE : (NODE))
-/* For a virtual function, the base where we find its vtable entry.
- For a non-virtual function, the base where it is defined. */
-#define DECL_VIRTUAL_CONTEXT(NODE) \
- (DECL_LANG_SPECIFIC (NODE)->u.f.context)
-
/* 1 iff NODE has namespace scope, including the global namespace. */
#define DECL_NAMESPACE_SCOPE_P(NODE) \
(!DECL_TEMPLATE_PARM_P (NODE) \