Commit 3461fba7 by Nathan Sidwell Committed by Nathan Sidwell

Remove old-abi remnants.

	Remove old-abi remnants. Remove comments about old abi
	behaviour. Remove refences to 'new-abi' in comments.
	* cp-tree.h: Adjust comments.
	(vbase_offsets_in_vtable_p): Delete.
	(vcall_offsets_in_vtable_p): Delete.
	(vptrs_present_everywhere_p): Delete.
	(all_overridden_vfuns_in_vtables_p): Delete.
	(merge_primary_and_secondary_vtables_p): Delete.
	(TYPE_CONTAINS_VPTR_P): Adjust.
	(VTT_NAME_PREFIX): Remove.
	(CTOR_VTBL_NAME_PREFIX): Remove.
	(init_vbase_pointers): Remove.
	* class.c: Adjust coments.
	(build_vbase_pointer_fields): Delete.
	(build_vbase_pointer): Remove old-abi code.
	(build_secondary_vtable): Likewise.
	(modify_all_vtables): Likewise.
	(create_vtable_ptr): Likewise.
	(layout_class_type): Likewise.
	(finish_struct_1): Likewise.
	(finish_vtbls): Likewise.
	(dfs_finish_vtbls): Delete.
	(build_vbase_offset_vtbl_entries): Remove old-abi code.
	* cvt.c: Adjust comments.
	* decl.c: Adjust comments.
	* decl2.c: Adjust comments.
	* init.c: Adjust comments.
	(construct_virtual_bases): Remove old-abi code.
	* lang-specs.h: Remove -fno-new-abi.
	* mangle.c: Adjust comments.
	* rtti.c: Adjust comments.
	(get_base_offset): Remove old-abi-code.
	* search.c: Adjust comments.
	(dfs_init_vbase_pointers): Remove.
	(dfs_vtable_path_unmark): Remove.
	(init_vbase_pointers): Remove.
	* semantics.c: Adjust comments.
	(emit_associated_thunks): Remove old-abi code.
	* typeck.c: Adjust comments.

From-SVN: r44215
parent 50b996bf
2001-07-20 Nathan Sidwell <nathan@codesourcery.com>
Remove old-abi remnants. Remove comments about old abi
behaviour. Remove refences to 'new-abi' in comments.
* cp-tree.h: Adjust comments.
(vbase_offsets_in_vtable_p): Delete.
(vcall_offsets_in_vtable_p): Delete.
(vptrs_present_everywhere_p): Delete.
(all_overridden_vfuns_in_vtables_p): Delete.
(merge_primary_and_secondary_vtables_p): Delete.
(TYPE_CONTAINS_VPTR_P): Adjust.
(VTT_NAME_PREFIX): Remove.
(CTOR_VTBL_NAME_PREFIX): Remove.
(init_vbase_pointers): Remove.
* class.c: Adjust coments.
(build_vbase_pointer_fields): Delete.
(build_vbase_pointer): Remove old-abi code.
(build_secondary_vtable): Likewise.
(modify_all_vtables): Likewise.
(create_vtable_ptr): Likewise.
(layout_class_type): Likewise.
(finish_struct_1): Likewise.
(finish_vtbls): Likewise.
(dfs_finish_vtbls): Delete.
(build_vbase_offset_vtbl_entries): Remove old-abi code.
* cvt.c: Adjust comments.
* decl.c: Adjust comments.
* decl2.c: Adjust comments.
* init.c: Adjust comments.
(construct_virtual_bases): Remove old-abi code.
* lang-specs.h: Remove -fno-new-abi.
* mangle.c: Adjust comments.
* rtti.c: Adjust comments.
(get_base_offset): Remove old-abi-code.
* search.c: Adjust comments.
(dfs_init_vbase_pointers): Remove.
(dfs_vtable_path_unmark): Remove.
(init_vbase_pointers): Remove.
* semantics.c: Adjust comments.
(emit_associated_thunks): Remove old-abi code.
* typeck.c: Adjust comments.
2001-07-20 Daniel Berlin <dan@cgsoftware.com>
* Make-lang.in (cp/optimize.o): Depend on $(PARAMS_H), not
......
......@@ -112,7 +112,6 @@ static tree get_vtable_name PARAMS ((tree));
static tree get_basefndecls PARAMS ((tree, tree));
static int build_primary_vtable PARAMS ((tree, tree));
static int build_secondary_vtable PARAMS ((tree, tree));
static tree dfs_finish_vtbls PARAMS ((tree, void *));
static void finish_vtbls PARAMS ((tree));
static void modify_vtable_entry PARAMS ((tree, tree, tree, tree, tree *));
static void add_virtual_function PARAMS ((tree *, tree *, int *, tree, tree));
......@@ -147,7 +146,6 @@ static bool build_base_field PARAMS ((record_layout_info, tree, int *,
splay_tree, tree));
static bool build_base_fields PARAMS ((record_layout_info, int *,
splay_tree, tree));
static tree build_vbase_pointer_fields PARAMS ((record_layout_info, int *));
static tree build_vtbl_or_vbase_field PARAMS ((tree, tree, tree, tree, tree,
int *));
static void check_methods PARAMS ((tree));
......@@ -241,84 +239,6 @@ int n_inner_fields_searched = 0;
/* Virtual base class layout. */
/* Returns a list of virtual base class pointers as a chain of
FIELD_DECLS. */
static tree
build_vbase_pointer_fields (rli, empty_p)
record_layout_info rli;
int *empty_p;
{
/* Chain to hold all the new FIELD_DECLs which point at virtual
base classes. */
tree rec = rli->t;
tree vbase_decls = NULL_TREE;
tree binfos = TYPE_BINFO_BASETYPES (rec);
int n_baseclasses = CLASSTYPE_N_BASECLASSES (rec);
tree decl;
int i;
/* Under the new ABI, there are no vbase pointers in the object.
Instead, the offsets are stored in the vtable. */
if (vbase_offsets_in_vtable_p ())
return NULL_TREE;
/* Loop over the baseclasses, adding vbase pointers as needed. */
for (i = 0; i < n_baseclasses; i++)
{
register tree base_binfo = TREE_VEC_ELT (binfos, i);
register tree basetype = BINFO_TYPE (base_binfo);
if (!COMPLETE_TYPE_P (basetype))
/* This error is now reported in xref_tag, thus giving better
location information. */
continue;
/* All basetypes are recorded in the association list of the
derived type. */
if (TREE_VIA_VIRTUAL (base_binfo))
{
int j;
const char *name;
/* The offset for a virtual base class is only used in computing
virtual function tables and for initializing virtual base
pointers. It is built once `get_vbase_types' is called. */
/* If this basetype can come from another vbase pointer
without an additional indirection, we will share
that pointer. If an indirection is involved, we
make our own pointer. */
for (j = 0; j < n_baseclasses; j++)
{
tree other_base_binfo = TREE_VEC_ELT (binfos, j);
if (! TREE_VIA_VIRTUAL (other_base_binfo)
&& binfo_for_vbase (basetype, BINFO_TYPE (other_base_binfo)))
goto got_it;
}
FORMAT_VBASE_NAME (name, basetype);
decl = build_vtbl_or_vbase_field (get_identifier (name),
get_identifier (VTABLE_BASE),
build_pointer_type (basetype),
rec,
basetype,
empty_p);
BINFO_VPTR_FIELD (base_binfo) = decl;
TREE_CHAIN (decl) = vbase_decls;
place_field (rli, decl);
vbase_decls = decl;
*empty_p = 0;
got_it:
/* The space this decl occupies has already been accounted for. */
;
}
}
return vbase_decls;
}
/* Returns a pointer to the virtual base class of EXP that has the
indicated TYPE. EXP is of class type, not a pointer type. */
......@@ -326,36 +246,27 @@ static tree
build_vbase_pointer (exp, type)
tree exp, type;
{
if (vbase_offsets_in_vtable_p ())
{
tree vbase;
tree vbase_ptr;
/* Find the shared copy of TYPE; that's where the vtable offset
is recorded. */
vbase = binfo_for_vbase (type, TREE_TYPE (exp));
/* Find the virtual function table pointer. */
vbase_ptr = build_vfield_ref (exp, TREE_TYPE (exp));
/* Compute the location where the offset will lie. */
vbase_ptr = build (PLUS_EXPR,
TREE_TYPE (vbase_ptr),
vbase_ptr,
BINFO_VPTR_FIELD (vbase));
vbase_ptr = build1 (NOP_EXPR,
build_pointer_type (ptrdiff_type_node),
vbase_ptr);
/* Add the contents of this location to EXP. */
return build (PLUS_EXPR,
build_pointer_type (type),
build_unary_op (ADDR_EXPR, exp, /*noconvert=*/0),
build1 (INDIRECT_REF, ptrdiff_type_node, vbase_ptr));
}
else
{
char *name;
FORMAT_VBASE_NAME (name, type);
return build_component_ref (exp, get_identifier (name), NULL_TREE, 0);
}
tree vbase;
tree vbase_ptr;
/* Find the shared copy of TYPE; that's where the vtable offset is
recorded. */
vbase = binfo_for_vbase (type, TREE_TYPE (exp));
/* Find the virtual function table pointer. */
vbase_ptr = build_vfield_ref (exp, TREE_TYPE (exp));
/* Compute the location where the offset will lie. */
vbase_ptr = build (PLUS_EXPR,
TREE_TYPE (vbase_ptr),
vbase_ptr,
BINFO_VPTR_FIELD (vbase));
vbase_ptr = build1 (NOP_EXPR,
build_pointer_type (ptrdiff_type_node),
vbase_ptr);
/* Add the contents of this location to EXP. */
return build (PLUS_EXPR,
build_pointer_type (type),
build_unary_op (ADDR_EXPR, exp, /*noconvert=*/0),
build1 (INDIRECT_REF, ptrdiff_type_node, vbase_ptr));
}
/* Build multi-level access to EXPR using hierarchy path PATH.
......@@ -603,8 +514,8 @@ build_vtbl_ref (instance, idx)
{
vtbl = TYPE_BINFO_VTABLE (basetype);
/* Knowing the dynamic type of INSTANCE we can easily obtain
the correct vtable entry. In the new ABI, we resolve
this back to be in terms of the primary vtable. */
the correct vtable entry. We resolve this back to be in
terms of the primary vtable. */
if (TREE_CODE (vtbl) == PLUS_EXPR)
{
idx = fold (build (PLUS_EXPR,
......@@ -818,15 +729,15 @@ build_primary_vtable (binfo, type)
return 1;
}
/* Give TYPE a new virtual function table which is initialized
/* Give BINFO a new virtual function table which is initialized
with a skeleton-copy of its original initialization. The only
entry that changes is the `delta' entry, so we can really
share a lot of structure.
FOR_TYPE is the derived type which caused this table to
FOR_TYPE is the most derived type which caused this table to
be needed.
BINFO is the type association which provided TYPE for FOR_TYPE.
Returns non-zero if we haven't met BINFO before.
The order in which vtables are built (by calling this function) for
an object must remain the same, otherwise a binary incompatibility
......@@ -836,143 +747,28 @@ static int
build_secondary_vtable (binfo, for_type)
tree binfo, for_type;
{
tree basetype;
tree orig_decl = BINFO_VTABLE (binfo);
tree name;
tree new_decl;
tree offset;
tree path = binfo;
char *buf;
const char *buf2;
char joiner = '_';
int i;
#ifdef JOINER
joiner = JOINER;
#endif
if (TREE_VIA_VIRTUAL (binfo))
my_friendly_assert (binfo == binfo_for_vbase (BINFO_TYPE (binfo),
current_class_type),
170);
my_friendly_assert (binfo == CANONICAL_BINFO (binfo, for_type), 20010605);
if (BINFO_NEW_VTABLE_MARKED (binfo, current_class_type))
if (BINFO_NEW_VTABLE_MARKED (binfo, for_type))
/* We already created a vtable for this base. There's no need to
do it again. */
return 0;
/* Remember that we've created a vtable for this BINFO, so that we
don't try to do so again. */
SET_BINFO_NEW_VTABLE_MARKED (binfo, current_class_type);
SET_BINFO_NEW_VTABLE_MARKED (binfo, for_type);
/* Make fresh virtual list, so we can smash it later. */
BINFO_VIRTUALS (binfo) = copy_virtuals (binfo);
my_friendly_assert (binfo == CANONICAL_BINFO (binfo, for_type), 20010605);
offset = BINFO_OFFSET (binfo);
/* In the new ABI, secondary vtables are laid out as part of the
same structure as the primary vtable. */
if (merge_primary_and_secondary_vtables_p ())
{
BINFO_VTABLE (binfo) = NULL_TREE;
return 1;
}
/* Create the declaration for the secondary vtable. */
basetype = TYPE_MAIN_VARIANT (BINFO_TYPE (binfo));
buf2 = TYPE_ASSEMBLER_NAME_STRING (basetype);
i = TYPE_ASSEMBLER_NAME_LENGTH (basetype) + 1;
/* We know that the vtable that we are going to create doesn't exist
yet in the global namespace, and when we finish, it will be
pushed into the global namespace. In complex MI hierarchies, we
have to loop while the name we are thinking of adding is globally
defined, adding more name components to the vtable name as we
loop, until the name is unique. This is because in complex MI
cases, we might have the same base more than once. This means
that the order in which this function is called for vtables must
remain the same, otherwise binary compatibility can be
compromised. */
while (1)
{
char *buf1 = (char *) alloca (TYPE_ASSEMBLER_NAME_LENGTH (for_type)
+ 1 + i);
char *new_buf2;
sprintf (buf1, "%s%c%s", TYPE_ASSEMBLER_NAME_STRING (for_type), joiner,
buf2);
buf = (char *) alloca (strlen (VTABLE_NAME_PREFIX) + strlen (buf1) + 1);
sprintf (buf, "%s%s", VTABLE_NAME_PREFIX, buf1);
name = get_identifier (buf);
/* If this name doesn't clash, then we can use it, otherwise
we add more to the name until it is unique. */
if (! IDENTIFIER_GLOBAL_VALUE (name))
break;
/* Set values for next loop through, if the name isn't unique. */
path = BINFO_INHERITANCE_CHAIN (path);
/* We better not run out of stuff to make it unique. */
my_friendly_assert (path != NULL_TREE, 368);
basetype = TYPE_MAIN_VARIANT (BINFO_TYPE (path));
if (for_type == basetype)
{
/* If we run out of basetypes in the path, we have already
found created a vtable with that name before, we now
resort to tacking on _%d to distinguish them. */
int j = 2;
i = TYPE_ASSEMBLER_NAME_LENGTH (basetype) + 1 + i + 1 + 3;
buf1 = (char *) alloca (i);
do {
sprintf (buf1, "%s%c%s%c%d",
TYPE_ASSEMBLER_NAME_STRING (basetype), joiner,
buf2, joiner, j);
buf = (char *) alloca (strlen (VTABLE_NAME_PREFIX)
+ strlen (buf1) + 1);
sprintf (buf, "%s%s", VTABLE_NAME_PREFIX, buf1);
name = get_identifier (buf);
/* If this name doesn't clash, then we can use it,
otherwise we add something different to the name until
it is unique. */
} while (++j <= 999 && IDENTIFIER_GLOBAL_VALUE (name));
/* Hey, they really like MI don't they? Increase the 3
above to 6, and the 999 to 999999. :-) */
my_friendly_assert (j <= 999, 369);
break;
}
i = TYPE_ASSEMBLER_NAME_LENGTH (basetype) + 1 + i;
new_buf2 = (char *) alloca (i);
sprintf (new_buf2, "%s%c%s",
TYPE_ASSEMBLER_NAME_STRING (basetype), joiner, buf2);
buf2 = new_buf2;
}
new_decl = build_vtable (for_type, name, TREE_TYPE (orig_decl));
DECL_ALIGN (new_decl) = DECL_ALIGN (orig_decl);
DECL_USER_ALIGN (new_decl) = DECL_USER_ALIGN (orig_decl);
BINFO_VTABLE (binfo) = pushdecl_top_level (new_decl);
#ifdef GATHER_STATISTICS
n_vtables += 1;
n_vtable_elems += list_length (BINFO_VIRTUALS (binfo));
#endif
/* Secondary vtables are laid out as part of the same structure as
the primary vtable. */
BINFO_VTABLE (binfo) = NULL_TREE;
return 1;
}
/* Create a new vtable for BINFO which is the hierarchy dominated by
T. */
T. Return non-zero if we actually created a new vtable. */
static int
make_new_vtable (t, binfo)
......@@ -1903,9 +1699,8 @@ determine_primary_base (t, vfuns_p)
if (!CLASSTYPE_HAS_PRIMARY_BASE_P (t))
CLASSTYPE_RTTI (t) = CLASSTYPE_RTTI (basetype);
/* A virtual baseclass can't be the primary base under the
old ABI. And under the new ABI we still prefer a
non-virtual base. */
/* We prefer a non-virtual base, although a virtual one will
do. */
if (TREE_VIA_VIRTUAL (base_binfo))
continue;
......@@ -1974,9 +1769,8 @@ determine_primary_base (t, vfuns_p)
}
}
/* The new ABI allows for the use of a "nearly-empty" virtual base
class as the primary base class if no non-virtual polymorphic
base can be found. */
/* A "nearly-empty" virtual base class can be the primary base
class, if no non-virtual polymorphic base can be found. */
if (!CLASSTYPE_HAS_PRIMARY_BASE_P (t))
{
/* If not NULL, this is the best primary base candidate we have
......@@ -2759,9 +2553,8 @@ update_vtable_entry_for_fn (t, binfo, fn, virtuals)
the final overrider, and not to an intermediate virtual base. */
virtual_base = NULL_TREE;
/* Under the new ABI, we will convert to an intermediate virtual
base first, and then use the vcall offset located there to finish
the conversion. */
/* We will convert to an intermediate virtual base first, and then
use the vcall offset located there to finish the conversion. */
while (b)
{
/* If we find the final overrider, then we can stop
......@@ -2851,9 +2644,6 @@ dfs_modify_vtables (binfo, data)
t = (tree) data;
/* If we're supporting RTTI then we always need a new vtable to
point to the RTTI information. Under the new ABI we may need
a new vtable to contain vcall and vbase offsets. */
make_new_vtable (t, binfo);
/* Now, go through each of the virtual functions in the virtual
......@@ -2890,9 +2680,8 @@ modify_all_vtables (t, vfuns_p, overridden_virtuals)
int *vfuns_p;
tree overridden_virtuals;
{
tree binfo;
binfo = TYPE_BINFO (t);
tree binfo = TYPE_BINFO (t);
tree *fnsp;
/* Update all of the vtables. */
dfs_walk (binfo,
......@@ -2901,43 +2690,35 @@ modify_all_vtables (t, vfuns_p, overridden_virtuals)
t);
dfs_walk (binfo, dfs_unmark, dfs_marked_real_bases_queue_p, t);
/* If we should include overriding functions for secondary vtables
in our primary vtable, add them now. */
if (all_overridden_vfuns_in_vtables_p ())
/* Include overriding functions for secondary vtables in our primary
vtable. */
for (fnsp = &overridden_virtuals; *fnsp; )
{
tree *fnsp = &overridden_virtuals;
tree fn = TREE_VALUE (*fnsp);
while (*fnsp)
if (!BINFO_VIRTUALS (binfo)
|| !value_member (fn, BINFO_VIRTUALS (binfo)))
{
tree fn = TREE_VALUE (*fnsp);
if (!BINFO_VIRTUALS (binfo)
|| !value_member (fn, BINFO_VIRTUALS (binfo)))
{
/* 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;
BV_VCALL_INDEX (*fnsp) = NULL_TREE;
/* This is an overridden function not already in our
vtable. Keep it. */
fnsp = &TREE_CHAIN (*fnsp);
}
else
/* We've already got an entry for this function. Skip
it. */
*fnsp = TREE_CHAIN (*fnsp);
/* 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;
BV_VCALL_INDEX (*fnsp) = NULL_TREE;
/* This is an overridden function not already in our
vtable. Keep it. */
fnsp = &TREE_CHAIN (*fnsp);
}
else
/* We've already got an entry for this function. Skip it. */
*fnsp = TREE_CHAIN (*fnsp);
}
else
overridden_virtuals = NULL_TREE;
return overridden_virtuals;
}
......@@ -4179,8 +3960,7 @@ build_base_fields (rli, empty_p, offsets, t)
int i;
bool atend = 0;
/* Under the new ABI, the primary base class is always allocated
first. */
/* The primary base class is always allocated first. */
if (CLASSTYPE_HAS_PRIMARY_BASE_P (rec))
build_base_field (rli, CLASSTYPE_PRIMARY_BINFO (rec),
empty_p, offsets, t);
......@@ -4192,8 +3972,8 @@ build_base_fields (rli, empty_p, offsets, t)
base_binfo = BINFO_BASETYPE (TYPE_BINFO (rec), i);
/* Under the new ABI, the primary base was already allocated
above, so we don't need to allocate it again here. */
/* The primary base was already allocated above, so we don't
need to allocate it again here. */
if (base_binfo == CLASSTYPE_PRIMARY_BINFO (rec))
continue;
......@@ -4710,9 +4490,7 @@ create_vtable_ptr (t, empty_p, vfuns_p,
here. Even if there weren't any new virtual functions, we might need a
new virtual function table if we're supposed to include vptrs in
all classes that need them. */
if (!TYPE_VFIELD (t)
&& (*vfuns_p
|| (TYPE_CONTAINS_VPTR_P (t) && vptrs_present_everywhere_p ())))
if (!TYPE_VFIELD (t) && (*vfuns_p || TYPE_CONTAINS_VPTR_P (t)))
{
/* We build this decl with vtbl_ptr_type_node, which is a
`vtable_entry_type*'. It might seem more precise to use
......@@ -4917,10 +4695,8 @@ layout_virtual_bases (t, offsets)
TYPE_ALIGN (t) = MAX (TYPE_ALIGN (t), BITS_PER_UNIT);
/* Go through the virtual bases, allocating space for each virtual
base that is not already a primary base class. Under the old
ABI, these are allocated according to a depth-first left-to-right
postorder traversal; in the new ABI, inheritance graph order is
used instead. */
base that is not already a primary base class. These are
allocated in inheritance graph order. */
for (vbases = TYPE_BINFO (t);
vbases;
vbases = TREE_CHAIN (vbases))
......@@ -4947,8 +4723,8 @@ layout_virtual_bases (t, offsets)
appropriately aligned offset. */
dsize = CEIL (dsize, desired_align) * desired_align;
/* Under the new ABI, we try to squish empty virtual bases in
just like ordinary empty bases. */
/* We try to squish empty virtual bases in just like
ordinary empty bases. */
if (is_empty_class (basetype))
layout_empty_base (vbase,
size_int (CEIL (dsize, BITS_PER_UNIT)),
......@@ -5130,8 +4906,7 @@ layout_class_type (t, empty_p, vfuns_p,
vptr = create_vtable_ptr (t, empty_p, vfuns_p,
new_virtuals_p, overridden_virtuals_p);
/* Under the new ABI, the vptr is always the first thing in the
class. */
/* The vptr is always the first thing in the class. */
if (vptr)
{
TYPE_FIELDS (t) = chainon (vptr, TYPE_FIELDS (t));
......@@ -5144,10 +4919,6 @@ layout_class_type (t, empty_p, vfuns_p,
if (build_base_fields (rli, empty_p, empty_base_offsets, t))
CLASSTYPE_NEARLY_EMPTY_P (t) = 0;
/* Add pointers to all of our virtual base-classes. */
TYPE_FIELDS (t) = chainon (build_vbase_pointer_fields (rli, empty_p),
TYPE_FIELDS (t));
/* CLASSTYPE_INLINE_FRIENDS is really TYPE_NONCOPIED_PARTS. Thus,
we have to save this before we start modifying
TYPE_NONCOPIED_PARTS. */
......@@ -5170,10 +4941,8 @@ layout_class_type (t, empty_p, vfuns_p,
type = TREE_TYPE (field);
/* If this field is a bit-field whose width is greater than its
type, then there are some special rules for allocating it
under the new ABI. Under the old ABI, there were no special
rules, but the back-end can't handle bitfields longer than a
`long long', so we use the same mechanism. */
type, then there are some special rules for allocating
it. */
if (DECL_C_BIT_FIELD (field)
&& INT_CST_LT (TYPE_SIZE (type), DECL_SIZE (field)))
{
......@@ -5238,10 +5007,10 @@ layout_class_type (t, empty_p, vfuns_p,
}
/* We make all structures have at least one element, so that they
have non-zero size. In the new ABI, the class may be empty even
if it has basetypes. Therefore, we add the fake field after all
the other fields; if there are already FIELD_DECLs on the list,
their offsets will not be disturbed. */
have non-zero size. The class may be empty even if it has
basetypes. Therefore, we add the fake field after all the other
fields; if there are already FIELD_DECLs on the list, their
offsets will not be disturbed. */
if (!eoc && *empty_p)
{
tree padding;
......@@ -5400,9 +5169,7 @@ finish_struct_1 (t)
= chainon (CLASSTYPE_VFIELDS (t), build_tree_list (NULL_TREE, t));
/* If necessary, create the primary vtable for this class. */
if (new_virtuals
|| overridden_virtuals
|| (TYPE_CONTAINS_VPTR_P (t) && vptrs_present_everywhere_p ()))
if (new_virtuals || overridden_virtuals || TYPE_CONTAINS_VPTR_P (t))
{
new_virtuals = nreverse (new_virtuals);
/* We must enter these virtuals into the table. */
......@@ -6779,10 +6546,9 @@ note_name_declared_in_class (name, decl)
}
}
/* Returns the VAR_DECL for the complete vtable associated with
BINFO. (Under the new ABI, secondary vtables are merged with
primary vtables; this function will return the VAR_DECL for the
primary vtable.) */
/* Returns the VAR_DECL for the complete vtable associated with BINFO.
Secondary vtables are merged with primary vtables; this function
will return the VAR_DECL for the primary vtable. */
tree
get_vtbl_decl_for_binfo (binfo)
......@@ -7130,64 +6896,34 @@ static void
finish_vtbls (t)
tree t;
{
if (merge_primary_and_secondary_vtables_p ())
{
tree list;
tree vbase;
tree list;
tree vbase;
/* Under the new ABI, we lay out the primary and secondary
vtables in one contiguous vtable. The primary vtable is
first, followed by the non-virtual secondary vtables in
inheritance graph order. */
list = build_tree_list (TYPE_BINFO_VTABLE (t), NULL_TREE);
accumulate_vtbl_inits (TYPE_BINFO (t), TYPE_BINFO (t),
TYPE_BINFO (t), t, list);
/* Then come the virtual bases, also in inheritance graph
order. */
for (vbase = TYPE_BINFO (t); vbase; vbase = TREE_CHAIN (vbase))
{
tree real_base;
/* We lay out the primary and secondary vtables in one contiguous
vtable. The primary vtable is first, followed by the non-virtual
secondary vtables in inheritance graph order. */
list = build_tree_list (TYPE_BINFO_VTABLE (t), NULL_TREE);
accumulate_vtbl_inits (TYPE_BINFO (t), TYPE_BINFO (t),
TYPE_BINFO (t), t, list);
/* Then come the virtual bases, also in inheritance graph order. */
for (vbase = TYPE_BINFO (t); vbase; vbase = TREE_CHAIN (vbase))
{
tree real_base;
if (!TREE_VIA_VIRTUAL (vbase))
continue;
if (!TREE_VIA_VIRTUAL (vbase))
continue;
/* Although we walk in inheritance order, that might not get the
canonical base. */
real_base = binfo_for_vbase (BINFO_TYPE (vbase), t);
/* Although we walk in inheritance order, that might not get the
canonical base. */
real_base = binfo_for_vbase (BINFO_TYPE (vbase), t);
accumulate_vtbl_inits (real_base, real_base,
TYPE_BINFO (t), t, list);
}
if (TYPE_BINFO_VTABLE (t))
initialize_vtable (TYPE_BINFO (t), TREE_VALUE (list));
}
else
{
dfs_walk (TYPE_BINFO (t), dfs_finish_vtbls,
dfs_unmarked_real_bases_queue_p, t);
dfs_walk (TYPE_BINFO (t), dfs_unmark,
dfs_marked_real_bases_queue_p, t);
accumulate_vtbl_inits (real_base, real_base,
TYPE_BINFO (t), t, list);
}
}
/* Called from finish_vtbls via dfs_walk. */
static tree
dfs_finish_vtbls (binfo, data)
tree binfo;
void *data;
{
tree t = (tree) data;
if (BINFO_NEW_VTABLE_MARKED (binfo, t))
initialize_vtable (binfo,
build_vtbl_initializer (binfo, binfo, t,
TYPE_BINFO (t), NULL));
SET_BINFO_MARKED (binfo);
return NULL_TREE;
if (TYPE_BINFO_VTABLE (t))
initialize_vtable (TYPE_BINFO (t), TREE_VALUE (list));
}
/* Initialize the vtable for BINFO with the INITS. */
......@@ -7666,9 +7402,8 @@ accumulate_vtbl_inits (binfo, orig_binfo, rtti_binfo, t, inits)
}
}
/* Called from accumulate_vtbl_inits when using the new ABI.
Accumulates the vtable initializers for all of the vtables into
TREE_VALUE (DATA). Returns the initializers for the BINFO vtable. */
/* Called from accumulate_vtbl_inits. Returns the initializers for
the BINFO vtable. */
static tree
dfs_accumulate_vtbl_inits (binfo, orig_binfo, rtti_binfo, t, l)
......@@ -7958,11 +7693,6 @@ build_vbase_offset_vtbl_entries (binfo, vid)
tree vbase;
tree t;
/* Under the old ABI, pointers to virtual bases are stored in each
object. */
if (!vbase_offsets_in_vtable_p ())
return;
/* If there are no virtual baseclasses, then there is nothing to
do. */
if (!TYPE_USES_VIRTUAL_BASECLASSES (BINFO_TYPE (binfo)))
......@@ -8039,11 +7769,6 @@ build_vcall_offset_vtbl_entries (binfo, vid)
tree binfo;
vtbl_init_data *vid;
{
/* Under the old ABI, the adjustments to the `this' pointer were made
elsewhere. */
if (!vcall_offsets_in_vtable_p ())
return;
/* We only need these entries if this base is a virtual base. */
if (!TREE_VIA_VIRTUAL (binfo))
return;
......
......@@ -133,11 +133,9 @@ Boston, MA 02111-1307, USA. */
The BV_FN is the declaration for the virtual function itself.
BINFO_VTABLE
Sometimes this is a VAR_DECL. Under the new ABI, it is instead
an expression with POINTER_TYPE pointing that gives the value
This is an expression with POINTER_TYPE that gives the value
to which the vptr should be initialized. Use get_vtbl_decl_for_binfo
to extract the VAR_DECL for the complete vtable; that macro works
in both ABIs.
to extract the VAR_DECL for the complete vtable.
DECL_ARGUMENTS
For a VAR_DECL this is DECL_ANON_UNION_ELEMS.
......@@ -224,40 +222,6 @@ extern int flag_rtti;
extern int flag_huge_objects;
/* Nonzero if virtual base class offsets are stored in the virtual
function table. Zero if, instead, a pointer to the virtual base is
stored in the object itself. */
#define vbase_offsets_in_vtable_p() (1)
/* Nonzero if displacements to the `this' pointer to use when calling
virtual functions in a virtual base class are present in the
vtable. */
#define vcall_offsets_in_vtable_p() (1)
/* Nonzero if a derived class that needs a vptr should always get one,
even if a non-primary base class already has one. For example,
given:
struct S { int i; virtual void f(); };
struct T : virtual public S {};
one could either reuse the vptr in `S' for `T', or create a new
vptr for `T'. If this flag is nonzero we choose the latter
alternative; otherwise, we choose the former. */
#define vptrs_present_everywhere_p() (1)
/* Nonzero if the vtable for a derived class should contain the
virtual functions from the primary base and all virtual functions
present in the class itself. Zero if, instead, it should contain
only those virtual functions from the primary base together with
the functions declared in the derived class (but not in any base
class). */
#define all_overridden_vfuns_in_vtables_p() (1)
/* Nonzero if primary and secondary vtables are combined into a single
vtable. */
#define merge_primary_and_secondary_vtables_p() (1)
/* Language-dependent contents of an identifier. */
......@@ -2431,8 +2395,7 @@ struct lang_decl
/* Nonzero if this class has a virtual function table pointer. */
#define TYPE_CONTAINS_VPTR_P(NODE) \
(TYPE_POLYMORPHIC_P (NODE) \
|| (vbase_offsets_in_vtable_p () \
&& TYPE_USES_VIRTUAL_BASECLASSES (NODE)))
|| TYPE_USES_VIRTUAL_BASECLASSES (NODE))
extern int flag_new_for_scope;
......@@ -2587,67 +2550,15 @@ extern int flag_new_for_scope;
/* A pointer-to-function member type looks like:
struct {
short __delta;
short __index;
union {
P __pfn;
short __delta2;
} __pfn_or_delta2;
};
where P is a POINTER_TYPE to a METHOD_TYPE appropriate for the
pointer to member. The fields are used as follows:
If __INDEX is -1, then the function to call is non-virtual, and
is located at the address given by __PFN.
If __INDEX is zero, then this a NULL pointer-to-member.
Otherwise, the function to call is virtual. Then, __DELTA2 gives
the offset from an instance of the object to the virtual function
table, and __INDEX - 1 is the index into the vtable to use to
find the function.
The value to use for the THIS parameter is the address of the
object plus __DELTA.
For example, given:
struct B1 {
int i;
};
struct B2 {
double d;
void f();
};
struct S : public B1, B2 {};
the pointer-to-member for `&S::f' looks like:
{ 4, -1, { &f__2B2 } };
The `4' means that given an `S*' you have to add 4 bytes to get to
the address of the `B2*'. Then, the -1 indicates that this is a
non-virtual function. Of course, `&f__2B2' is the name of that
function.
(Of course, the exact values may differ depending on the mangling
scheme, sizes of types, and such.).
Under the new ABI, we do:
struct {
__P __pfn;
ptrdiff_t __delta;
};
(We don't need DELTA2, because the vtable is always the first thing
in the object.) If the function is virtual, then PFN is one plus
twice the index into the vtable; otherwise, it is just a pointer to
the function.
(As the vtable is always the first thing in the object, we don't
need an offset to it.) If the function is virtual, then PFN is one
plus twice the index into the vtable; otherwise, it is just a
pointer to the function.
Unfortunately, using the lowest bit of PFN doesn't work in
architectures that don't impose alignment requirements on function
......@@ -3342,15 +3253,6 @@ extern varray_type local_classes;
#define EXCEPTION_CLEANUP_NAME "exception cleanup"
/* The name used as a prefix for VTTs. When the new ABI mangling
scheme is implemented, this should be removed. */
#define VTT_NAME_PREFIX "__vtt_"
/* The name used as a prefix for construction vtables. */
#define CTOR_VTBL_NAME_PREFIX "__ctorvt_"
#define THIS_NAME_P(ID_NODE) (strcmp(IDENTIFIER_POINTER (ID_NODE), "this") == 0)
#if !defined(NO_DOLLAR_IN_LABEL) || !defined(NO_DOT_IN_LABEL)
......@@ -4165,7 +4067,6 @@ extern tree lookup_fnfields PARAMS ((tree, tree, int));
extern tree lookup_member PARAMS ((tree, tree, int, int));
extern int look_for_overrides PARAMS ((tree, tree));
extern void get_pure_virtuals PARAMS ((tree));
extern tree init_vbase_pointers PARAMS ((tree, tree));
extern void get_vbase_types PARAMS ((tree));
extern void maybe_suppress_debug_info PARAMS ((tree));
extern void note_debug_info_needed PARAMS ((tree));
......
......@@ -259,8 +259,8 @@ cp_convert_to_pointer (type, expr, force)
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0);
if (TYPE_PTRMEM_P (type))
/* Under the new ABI, a NULL pointer-to-member is represented
by -1, not by zero. */
/* A NULL pointer-to-member is represented by -1, not by
zero. */
expr = build_int_2 (-1, -1);
else
expr = build_int_2 (0, 0);
......
......@@ -48,8 +48,7 @@ Boston, MA 02111-1307, USA. */
extern int (*valid_lang_attribute) PARAMS ((tree, tree, tree, tree));
#ifndef BOOL_TYPE_SIZE
/* In the new ABI, `bool' has size and alignment `1', on all
platforms. */
/* `bool' has size and alignment `1', on all platforms. */
#define BOOL_TYPE_SIZE CHAR_TYPE_SIZE
#endif
......@@ -9475,7 +9474,6 @@ check_special_function_return_type (sfk, type, optype)
if (type)
cp_error ("return type specification for constructor invalid");
/* In the new ABI constructors do not return a value. */
type = void_type_node;
break;
......
......@@ -2291,12 +2291,12 @@ comdat_linkage (decl)
address, and this will not hold when we emit multiple copies of
the function. However, there's little else we can do.
Also, by default, the typeinfo implementation for the new ABI
assumes that there will be only one copy of the string used as
the name for each type. Therefore, if weak symbols are
unavailable, the run-time library should perform a more
conservative check; it should perform a string comparison,
rather than an address comparison. */
Also, by default, the typeinfo implementation assumes that
there will be only one copy of the string used as the name for
each type. Therefore, if weak symbols are unavailable, the
run-time library should perform a more conservative check; it
should perform a string comparison, rather than an address
comparison. */
TREE_PUBLIC (decl) = 0;
else
{
......@@ -2744,8 +2744,8 @@ get_guard (decl)
{
tree guard_type;
/* Under the new ABI, we use a type that is big enough to
contain a mutex as well as an integer counter. */
/* We use a type that is big enough to contain a mutex as well
as an integer counter. */
guard_type = long_long_integer_type_node;
guard = build_decl (VAR_DECL, sname, guard_type);
......@@ -2772,8 +2772,8 @@ static tree
get_guard_bits (guard)
tree guard;
{
/* Under the new ABI, we only set the first byte of the guard,
in order to leave room for a mutex in the high-order bits. */
/* We only set the first byte of the guard, in order to leave room
for a mutex in the high-order bits. */
guard = build1 (ADDR_EXPR,
build_pointer_type (TREE_TYPE (guard)),
guard);
......
......@@ -175,9 +175,9 @@ initialize_vtbl_ptrs (addr)
list = build_tree_list (type, addr);
/* Walk through the hierarchy, initializing the vptr in each base
class. We do these in pre-order because under the new ABI we
can't find the virtual bases for a class until we've initialized
the vtbl for that class. */
class. We do these in pre-order because can't find the virtual
bases for a class until we've initialized the vtbl for that
class. */
dfs_walk_real (TYPE_BINFO (type), dfs_initialize_vtbl_ptrs,
NULL, dfs_unmarked_real_bases_queue_p, list);
dfs_walk (TYPE_BINFO (type), dfs_unmark,
......@@ -851,8 +851,8 @@ expand_virtual_init (binfo, decl)
/* Compute the initializer for vptr. */
vtbl = build_vtbl_address (binfo);
/* Under the new ABI, we may get this vptr from a VTT, if this is a
subobject constructor or subobject destructor. */
/* We may get this vptr from a VTT, if this is a subobject
constructor or subobject destructor. */
vtt_index = BINFO_VPTR_INDEX (binfo);
if (vtt_index)
{
......@@ -951,22 +951,6 @@ construct_virtual_bases (type, this_ref, this_ptr, init_list, flag)
/* If there are no virtual baseclasses, we shouldn't even be here. */
my_friendly_assert (TYPE_USES_VIRTUAL_BASECLASSES (type), 19990621);
/* First set the pointers in our object that tell us where to find
our virtual baseclasses. */
if (!vbase_offsets_in_vtable_p ())
{
tree if_stmt;
tree result;
if_stmt = begin_if_stmt ();
finish_if_stmt_cond (flag, if_stmt);
result = init_vbase_pointers (type, this_ptr);
if (result)
finish_expr_stmt (build_compound_expr (result));
finish_then_clause (if_stmt);
finish_if_stmt ();
}
/* Now, run through the baseclasses, initializing each. */
for (vbases = CLASSTYPE_VBASECLASSES (type); vbases;
vbases = TREE_CHAIN (vbases))
......@@ -2213,7 +2197,7 @@ build_java_class_ref (type)
jclass_node = TREE_TYPE (jclass_node);
}
/* Mangle the class$ field, new and old ABI */
/* Mangle the class$ field */
{
tree field;
for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
......@@ -2252,8 +2236,8 @@ get_cookie_size (type)
{
tree cookie_size;
/* Under the new ABI, we need to allocate an additional max
(sizeof (size_t), alignof (true_type)) bytes. */
/* We need to allocate an additional max (sizeof (size_t), alignof
(true_type)) bytes. */
tree sizetype_size;
tree type_align;
......@@ -2360,9 +2344,7 @@ build_new_1 (exp)
if (!has_array || !TYPE_VEC_NEW_USES_COOKIE (true_type))
use_cookie = 0;
/* When using placement new, users may not realize that they need
the extra storage. Under the old ABI, we don't allocate the
cookie whenever they use one placement argument of type `void
*'. Under the new ABI, we require that the operator called be
the extra storage. We require that the operator called be
the global placement operator delete[]. */
else if (placement && !TREE_CHAIN (placement)
&& same_type_p (TREE_TYPE (TREE_VALUE (placement)),
......@@ -2479,9 +2461,8 @@ build_new_1 (exp)
tree cookie;
/* Store the number of bytes allocated so that we can know how
many elements to destroy later. Under the new ABI, we use
the last sizeof (size_t) bytes to store the number of
elements. */
many elements to destroy later. We use the last sizeof
(size_t) bytes to store the number of elements. */
cookie = build (MINUS_EXPR, build_pointer_type (sizetype),
alloc_node, size_in_bytes (sizetype));
cookie = build_indirect_ref (cookie, NULL);
......
......@@ -38,14 +38,14 @@ Boston, MA 02111-1307, USA. */
"%{E|M|MM:cpp0 -lang-c++ %{!no-gcc:-D__GNUG__=%v1}\
%{!Wno-deprecated:-D__DEPRECATED}\
%{!fno-exceptions:-D__EXCEPTIONS}\
%{!fno-new-abi:-D__GXX_ABI_VERSION=100}\
-D__GXX_ABI_VERSION=100\
%{ansi:-D__STRICT_ANSI__ -trigraphs -$} %(cpp_options)}\
%{!E:%{!M:%{!MM:\
%{save-temps:cpp0 -lang-c++ \
%{!no-gcc:-D__GNUG__=%v1}\
%{!Wno-deprecated:-D__DEPRECATED}\
%{!fno-exceptions:-D__EXCEPTIONS}\
%{!fno-new-abi:-D__GXX_ABI_VERSION=100}\
-D__GXX_ABI_VERSION=100\
%{ansi:-D__STRICT_ANSI__ -trigraphs -$}\
%(cpp_options) %b.ii \n}\
cc1plus %{save-temps:-fpreprocessed %b.ii}\
......@@ -53,7 +53,7 @@ Boston, MA 02111-1307, USA. */
%{!no-gcc:-D__GNUG__=%v1} \
%{!Wno-deprecated:-D__DEPRECATED}\
%{!fno-exceptions:-D__EXCEPTIONS}\
%{!fno-new-abi:-D__GXX_ABI_VERSION=100}\
-D__GXX_ABI_VERSION=100\
%{ansi:-D__STRICT_ANSI__}}\
%{ansi:-trigraphs -$}\
%(cc1_options) %2 %{+e1*}\
......
/* Name mangling for the new standard C++ ABI.
/* Name mangling for the 3.0 C++ ABI.
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
Written by Alex Samuel <sameul@codesourcery.com>
......@@ -1168,10 +1168,9 @@ write_identifier (identifier)
Currently, allocating constructors are never used.
We also need to provide unique mangled names (which should never be
exported) for the constructor that takes an in-charge parameter,
and for a constructor whose name is the same as its class's name.
We use "C*INTERNAL*" for these. */
We also need to provide mangled names for the maybe-in-charge
constructor, so we treat it here too. mangle_decl_string will
append *INTERNAL* to that, to make sure we never emit it. */
static void
write_special_name_constructor (ctor)
......@@ -1190,15 +1189,15 @@ write_special_name_constructor (ctor)
}
/* Handle destructor productions of non-terminal <special-name>.
DTOR is a denstructor FUNCTION_DECL.
DTOR is a destructor FUNCTION_DECL.
<special-name> ::= D0 # deleting (in-charge) destructor
::= D1 # complete object (in-charge) destructor
::= D2 # base object (not-in-charge) destructor
::= D2 # base object (not-in-charge) destructor
We also need to provide unique mngled names for old-ABI
destructors, sometimes. These should only be used internally. We
use "D*INTERNAL*" for these. */
We also need to provide mangled names for the maybe-incharge
destructor, so we treat it here too. mangle_decl_string will
append *INTERNAL* to that, to make sure we never emit it. */
static void
write_special_name_destructor (dtor)
......
......@@ -130,8 +130,7 @@ build_headof (exp)
/* We use this a couple of times below, protect it. */
exp = save_expr (exp);
/* Under the new ABI, the offset-to-top field is at index -2 from
the vptr. */
/* The offset-to-top field is at index -2 from the vptr. */
index = build_int_2 (-2, -1);
aref = build_vtbl_ref (build_indirect_ref (exp, NULL), index);
......@@ -452,36 +451,12 @@ get_base_offset (binfo, parent)
{
if (! TREE_VIA_VIRTUAL (binfo))
return BINFO_OFFSET (binfo);
else if (! vbase_offsets_in_vtable_p ())
{
const char *name;
tree result;
tree field;
FORMAT_VBASE_NAME (name, BINFO_TYPE (binfo));
field = lookup_field (parent, get_identifier (name), 0, 0);
result = byte_position (field);
if (DECL_CONTEXT (field) != parent)
{
/* The vbase pointer might be in a non-virtual base of PARENT.
* Adjust for the offset of that base in PARENT. */
tree path;
get_base_distance (DECL_CONTEXT (field), parent, -1, &path);
result = build (PLUS_EXPR, TREE_TYPE (result),
result, BINFO_OFFSET (path));
result = fold (result);
}
return result;
}
else
/* Under the new ABI, we store the vtable offset at which
the virtual base offset can be found. */
/* We store the vtable offset at which the virtual base offset can
be found. */
return convert (sizetype,
BINFO_VPTR_FIELD (binfo_for_vbase (BINFO_TYPE (binfo),
parent)));
}
/* Execute a dynamic cast, as described in section 5.2.6 of the 9/93 working
......@@ -833,8 +808,8 @@ tinfo_base_init (desc, target)
DECL_EXTERNAL (name_decl) = 0;
TREE_PUBLIC (name_decl) = 1;
comdat_linkage (name_decl);
/* The new ABI specifies the external name of the string
containing the type's name. */
/* External name of the string containing the type's name has a
special name. */
SET_DECL_ASSEMBLER_NAME (name_decl,
mangle_typeinfo_string_for_type (target));
DECL_INITIAL (name_decl) = name_string;
......@@ -1295,8 +1270,7 @@ create_pseudo_type_info VPARAMS((const char *real_name, int ident, ...))
vtable_decl = get_vtable_decl (real_type, /*complete=*/1);
vtable_decl = build_unary_op (ADDR_EXPR, vtable_decl, 0);
/* Under the new ABI, we need to point into the middle of the
vtable. */
/* We need to point into the middle of the vtable. */
vtable_decl = build (PLUS_EXPR,
TREE_TYPE (vtable_decl),
vtable_decl,
......
......@@ -102,7 +102,6 @@ static tree marked_pushdecls_p PARAMS ((tree, void *));
static tree unmarked_pushdecls_p PARAMS ((tree, void *));
static tree dfs_debug_unmarkedp PARAMS ((tree, void *));
static tree dfs_debug_mark PARAMS ((tree, void *));
static tree dfs_init_vbase_pointers PARAMS ((tree, void *));
static tree dfs_get_vbase_types PARAMS ((tree, void *));
static tree dfs_push_type_decls PARAMS ((tree, void *));
static tree dfs_push_decls PARAMS ((tree, void *));
......@@ -140,7 +139,6 @@ static tree get_shared_vbase_if_not_primary PARAMS ((tree, void *));
static tree dfs_find_vbase_instance PARAMS ((tree, void *));
static tree dfs_get_pure_virtuals PARAMS ((tree, void *));
static tree dfs_build_inheritance_graph_order PARAMS ((tree, void *));
static tree dfs_vtable_path_unmark PARAMS ((tree, void *));
/* Allocate a level of searching. */
......@@ -2335,108 +2333,6 @@ dfs_unmark (binfo, data)
}
static tree
dfs_init_vbase_pointers (binfo, data)
tree binfo;
void *data;
{
struct vbase_info *vi = (struct vbase_info *) data;
tree type = BINFO_TYPE (binfo);
tree fields;
tree this_vbase_ptr;
/* Don't initialize the same base more than once. */
SET_BINFO_VTABLE_PATH_MARKED (binfo);
/* We know that VI->DECL_PTR points to the complete object. So,
finding a pointer to this subobject is easy. */
this_vbase_ptr = build (PLUS_EXPR,
build_pointer_type (type),
vi->decl_ptr,
BINFO_OFFSET (binfo));
/* We're going to iterate through all the pointers to virtual
base-classes. They come at the beginning of the class. */
fields = TYPE_FIELDS (type);
if (fields == NULL_TREE
|| DECL_NAME (fields) == NULL_TREE
|| ! VBASE_NAME_P (DECL_NAME (fields)))
return NULL_TREE;
if (build_pointer_type (type)
!= TYPE_MAIN_VARIANT (TREE_TYPE (this_vbase_ptr)))
my_friendly_abort (125);
while (fields && DECL_NAME (fields) && VBASE_NAME_P (DECL_NAME (fields)))
{
tree ref = build (COMPONENT_REF, TREE_TYPE (fields),
build_indirect_ref (this_vbase_ptr, NULL), fields);
tree init;
tree vbase_type;
tree vbase_binfo;
vbase_type = TREE_TYPE (TREE_TYPE (fields));
vbase_binfo = binfo_for_vbase (vbase_type, vi->type);
init = build (PLUS_EXPR,
build_pointer_type (vbase_type),
vi->decl_ptr,
BINFO_OFFSET (vbase_binfo));
vi->inits
= tree_cons (vbase_binfo,
build_modify_expr (ref, NOP_EXPR, init),
vi->inits);
fields = TREE_CHAIN (fields);
}
return NULL_TREE;
}
/* Call CLEAR_BINFO_VTABLE_PATH_MARKED for BINFO. */
static tree
dfs_vtable_path_unmark (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
CLEAR_BINFO_VTABLE_PATH_MARKED (binfo);
return NULL_TREE;
}
tree
init_vbase_pointers (type, decl_ptr)
tree type;
tree decl_ptr;
{
my_friendly_assert (!vbase_offsets_in_vtable_p (), 20000516);
if (TYPE_USES_VIRTUAL_BASECLASSES (type))
{
struct vbase_info vi;
tree binfo = TYPE_BINFO (type);
/* Find all the virtual base classes, marking them for later
initialization. */
vi.type = type;
vi.decl_ptr = decl_ptr;
vi.inits = NULL_TREE;
/* Build up a list of the initializers. */
dfs_walk_real (binfo,
dfs_init_vbase_pointers, 0,
unmarked_vtable_pathp,
&vi);
dfs_walk (binfo,
dfs_vtable_path_unmark,
marked_vtable_pathp,
NULL);
return vi.inits;
}
return 0;
}
/* get the virtual context (the vbase that directly contains the
DECL_CONTEXT of the FNDECL) that the given FNDECL is declared in,
or NULL_TREE if there is none.
......
......@@ -2337,7 +2337,7 @@ emit_associated_thunks (fn)
is so that you can know statically the entire set of thunks that
will ever be needed for a given virtual function, thereby
enabling you to output all the thunks with the function itself. */
if (vcall_offsets_in_vtable_p () && DECL_VIRTUAL_P (fn))
if (DECL_VIRTUAL_P (fn))
{
tree binfo;
tree v;
......@@ -2403,8 +2403,8 @@ expand_body (fn)
simplify_aggr_init_exprs_r,
NULL);
/* If this is a constructor or destructor body, we have to clone it
under the new ABI. */
/* If this is a constructor or destructor body, we have to clone
it. */
if (maybe_clone_body (fn))
{
/* We don't want to process FN again, so pretend we've written
......
......@@ -6105,8 +6105,7 @@ build_ptrmemfunc (type, pfn, force)
delta = build_component_ref (pfn, delta_identifier, NULL_TREE, 0);
}
/* Under the new ABI, the conversion is easy. Just adjust
the DELTA field. */
/* Just adjust the DELTA field. */
delta = cp_convert (ptrdiff_type_node, delta);
if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta)
n = cp_build_binary_op (LSHIFT_EXPR, n, integer_one_node);
......@@ -6171,10 +6170,9 @@ expand_ptrmemfunc_cst (cst, delta, pfn)
*delta = fold (build (PLUS_EXPR, TREE_TYPE (*delta),
*delta, BINFO_OFFSET (binfo)));
/* Under the new ABI, we set PFN to the vtable offset at
which the function can be found, plus one (unless
ptrmemfunc_vbit_in_delta, in which case delta is shifted
left, and then incremented). */
/* We set PFN to the vtable offset at which the function can be
found, plus one (unless ptrmemfunc_vbit_in_delta, in which
case delta is shifted left, and then incremented). */
*pfn = DECL_VINDEX (fn);
*pfn = fold (build (MULT_EXPR, integer_type_node, *pfn,
TYPE_SIZE_UNIT (vtable_entry_type)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment