Commit fc6633e0 by Nathan Sidwell Committed by Nathan Sidwell

tree.h (BINFO_PRIMARY_BASE_OF): Remove.

	* tree.h (BINFO_PRIMARY_BASE_OF): Remove.
	(struct tree_binfo): Remove primary field.
	* cp/cp-tree.h (BINFO_PRIMARY_P): Use a binfo flag.
	(BINFO_INDIRECT_PRIMARY_P): Remove.
	* cp/class.c (determine_primary_base): Rename to ...
	(determine_primary_bases): ... here.  Set all primary bases.
	(set_primary_base): Remove.
	(mark_primary_bases): Remove.
	(build_simple_base_path, walk_subobject_offsets,
	propagate_binfo_offsets, end_of_class): Adjust.
	(layout_class_type): Rename determine_primary_base call.
	(dump_class_hierarchy_r, dump_vtable): Adjust. Don't pass a binfo
	to type_as_string.
	(dfs_build_secondary_vptr_vtt_inits, dfs_accumulate_vtbl_inits,
	build_rtti_vtbl_entries): Adjust.
	* cp/init.c (build_vtbl_address): Adjust.

From-SVN: r86766
parent bd8a2e96
2004-08-30 Nathan Sidwell <nathan@codesourcery.com>
* tree.h (BINFO_PRIMARY_BASE_OF): Remove.
(struct tree_binfo): Remove primary field.
2004-08-30 Paolo Bonzini <bonzini@gnu.org> 2004-08-30 Paolo Bonzini <bonzini@gnu.org>
* configure.ac: Do not run fixincludes after stage1 during * configure.ac: Do not run fixincludes after stage1 during
...@@ -9,6 +14,12 @@ ...@@ -9,6 +14,12 @@
* sched-deps.c (get_condition): Partially revert previous, by never * sched-deps.c (get_condition): Partially revert previous, by never
trying to extract the condition from a condjump. trying to extract the condition from a condjump.
2004-08-30 Nathan Sidwell <nathan@codesourcery.com>
* c-common.c (c_sizeof_or_alignof_type): Use gcc_assert.
(handle_visibility_attribute, c_determine_visibility): Likewise.
* c-common.h (my_friendly_assert): Remove.
2004-08-30 Richard Sandiford <rsandifo@redhat.com> 2004-08-30 Richard Sandiford <rsandifo@redhat.com>
* config/mips/mips.md (UNSPEC_{RSQRT,RECIP}[12]_{S,D,PS}): Delete. * config/mips/mips.md (UNSPEC_{RSQRT,RECIP}[12]_{S,D,PS}): Delete.
......
2004-08-30 Nathan Sidwell <nathan@codesourcery.com> 2004-08-30 Nathan Sidwell <nathan@codesourcery.com>
* cp-tree.h (BINFO_PRIMARY_P): Use a binfo flag.
(BINFO_INDIRECT_PRIMARY_P): Remove.
* class.c (determine_primary_base): Rename to ...
(determine_primary_bases): ... here. Set all primary bases.
(set_primary_base): Remove.
(mark_primary_bases): Remove.
(build_simple_base_path, walk_subobject_offsets,
propagate_binfo_offsets, end_of_class): Adjust.
(layout_class_type): Rename determine_primary_base call.
(dump_class_hierarchy_r, dump_vtable): Adjust. Don't pass a binfo
to type_as_string.
(dfs_build_secondary_vptr_vtt_inits, dfs_accumulate_vtbl_inits,
build_rtti_vtbl_entries): Adjust.
* init.c (build_vtbl_address): Adjust.
* cp-tree.h (SET_BINFO_NEW_VTABLE_MARKED): Use gcc_assert. * cp-tree.h (SET_BINFO_NEW_VTABLE_MARKED): Use gcc_assert.
2004-08-28 Ziemowit Laski <zlaski@apple.com> 2004-08-28 Ziemowit Laski <zlaski@apple.com>
......
...@@ -119,7 +119,7 @@ static void handle_using_decl (tree, tree); ...@@ -119,7 +119,7 @@ static void handle_using_decl (tree, tree);
static void check_for_override (tree, tree); static void check_for_override (tree, tree);
static tree dfs_modify_vtables (tree, void *); static tree dfs_modify_vtables (tree, void *);
static tree modify_all_vtables (tree, tree); static tree modify_all_vtables (tree, tree);
static void determine_primary_base (tree); static void determine_primary_bases (tree);
static void finish_struct_methods (tree); static void finish_struct_methods (tree);
static void maybe_warn_about_overly_private_class (tree); static void maybe_warn_about_overly_private_class (tree);
static int method_name_cmp (const void *, const void *); static int method_name_cmp (const void *, const void *);
...@@ -147,7 +147,6 @@ static void include_empty_classes (record_layout_info); ...@@ -147,7 +147,6 @@ static void include_empty_classes (record_layout_info);
static void layout_class_type (tree, tree *); static void layout_class_type (tree, tree *);
static void fixup_pending_inline (tree); static void fixup_pending_inline (tree);
static void fixup_inline_methods (tree); static void fixup_inline_methods (tree);
static void set_primary_base (tree, tree);
static void propagate_binfo_offsets (tree, tree); static void propagate_binfo_offsets (tree, tree);
static void layout_virtual_bases (record_layout_info, splay_tree); static void layout_virtual_bases (record_layout_info, splay_tree);
static void build_vbase_offset_vtbl_entries (tree, vtbl_init_data *); static void build_vbase_offset_vtbl_entries (tree, vtbl_init_data *);
...@@ -182,7 +181,6 @@ static tree dfs_accumulate_vtbl_inits (tree, tree, tree, tree, ...@@ -182,7 +181,6 @@ static tree dfs_accumulate_vtbl_inits (tree, tree, tree, tree,
static void build_rtti_vtbl_entries (tree, vtbl_init_data *); static void build_rtti_vtbl_entries (tree, vtbl_init_data *);
static void build_vcall_and_vbase_vtbl_entries (tree, static void build_vcall_and_vbase_vtbl_entries (tree,
vtbl_init_data *); vtbl_init_data *);
static void mark_primary_bases (tree);
static void clone_constructors_and_destructors (tree); static void clone_constructors_and_destructors (tree);
static tree build_clone (tree, tree); static tree build_clone (tree, tree);
static void update_vtable_entry_for_fn (tree, tree, tree, tree *, unsigned); static void update_vtable_entry_for_fn (tree, tree, tree, tree *, unsigned);
...@@ -415,15 +413,9 @@ static tree ...@@ -415,15 +413,9 @@ static tree
build_simple_base_path (tree expr, tree binfo) build_simple_base_path (tree expr, tree binfo)
{ {
tree type = BINFO_TYPE (binfo); tree type = BINFO_TYPE (binfo);
tree d_binfo; tree d_binfo = BINFO_INHERITANCE_CHAIN (binfo);
tree field; tree field;
/* For primary virtual bases, we can't just follow
BINFO_INHERITANCE_CHAIN. */
d_binfo = BINFO_PRIMARY_BASE_OF (binfo);
if (d_binfo == NULL_TREE)
d_binfo = BINFO_INHERITANCE_CHAIN (binfo);
if (d_binfo == NULL_TREE) if (d_binfo == NULL_TREE)
{ {
if (TYPE_MAIN_VARIANT (TREE_TYPE (expr)) != type) if (TYPE_MAIN_VARIANT (TREE_TYPE (expr)) != type)
...@@ -1254,170 +1246,132 @@ check_bases (tree t, ...@@ -1254,170 +1246,132 @@ check_bases (tree t,
} }
} }
/* Set BINFO_PRIMARY_BASE_OF for all binfos in the hierarchy /* Determine all the primary bases within T. Sets BINFO_PRIMARY_BASE_P for
dominated by TYPE that are primary bases. */ those that are primaries. Sets BINFO_LOST_PRIMARY_P for those
that have had a nearly-empty virtual primary base stolen by some
other base in the heirarchy. Determines CLASSTYPE_PRIMARY_BASE for
T. */
static void static void
mark_primary_bases (tree type) determine_primary_bases (tree t)
{ {
tree binfo; unsigned i;
tree primary = NULL_TREE;
tree type_binfo = TYPE_BINFO (t);
tree base_binfo;
/* Walk the bases in inheritance graph order. */ /* Determine the primary bases of our bases. */
for (binfo = TYPE_BINFO (type); binfo; binfo = TREE_CHAIN (binfo)) for (base_binfo = TREE_CHAIN (type_binfo); base_binfo;
base_binfo = TREE_CHAIN (base_binfo))
{
tree primary = CLASSTYPE_PRIMARY_BINFO (BINFO_TYPE (base_binfo));
/* See if we're the non-virtual primary of our inheritance
chain. */
if (!BINFO_VIRTUAL_P (base_binfo))
{ {
tree base_binfo = get_primary_binfo (binfo); tree parent = BINFO_INHERITANCE_CHAIN (base_binfo);
tree parent_primary = CLASSTYPE_PRIMARY_BINFO (BINFO_TYPE (parent));
if (!base_binfo) if (parent_primary
/* Not a dynamic base. */; && BINFO_TYPE (base_binfo) == BINFO_TYPE (parent_primary))
else if (BINFO_PRIMARY_P (base_binfo)) /* We are the primary binfo. */
BINFO_LOST_PRIMARY_P (binfo) = 1; BINFO_PRIMARY_P (base_binfo) = 1;
}
/* Determine if we have a virtual primary base, and mark it so.
*/
if (primary && BINFO_VIRTUAL_P (primary))
{
tree this_primary = copied_binfo (primary, base_binfo);
if (BINFO_PRIMARY_P (this_primary))
/* Someone already claimed this base. */
BINFO_LOST_PRIMARY_P (base_binfo) = 1;
else else
{ {
BINFO_PRIMARY_BASE_OF (base_binfo) = binfo; tree delta;
BINFO_PRIMARY_P (this_primary) = 1;
BINFO_INHERITANCE_CHAIN (this_primary) = base_binfo;
/* A virtual binfo might have been copied from within /* A virtual binfo might have been copied from within
another hierarchy. As we're about to use it as a primary another hierarchy. As we're about to use it as a
base, make sure the offsets match. */ primary base, make sure the offsets match. */
if (BINFO_VIRTUAL_P (base_binfo)) delta = size_diffop (convert (ssizetype,
{ BINFO_OFFSET (base_binfo)),
tree delta = size_diffop (convert (ssizetype,
BINFO_OFFSET (binfo)),
convert (ssizetype, convert (ssizetype,
BINFO_OFFSET (base_binfo))); BINFO_OFFSET (this_primary)));
propagate_binfo_offsets (base_binfo, delta); propagate_binfo_offsets (this_primary, delta);
} }
} }
} }
}
/* Make the BINFO the primary base of T. */
static void
set_primary_base (tree t, tree binfo)
{
tree basetype;
CLASSTYPE_PRIMARY_BINFO (t) = binfo;
basetype = BINFO_TYPE (binfo);
BINFO_VTABLE (TYPE_BINFO (t)) = BINFO_VTABLE (TYPE_BINFO (basetype));
BINFO_VIRTUALS (TYPE_BINFO (t)) = BINFO_VIRTUALS (TYPE_BINFO (basetype));
TYPE_VFIELD (t) = TYPE_VFIELD (basetype);
}
/* Determine the primary class for T. */
static void
determine_primary_base (tree t)
{
unsigned i, n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t));
tree type_binfo = TYPE_BINFO (t);
tree vbase_binfo;
tree base_binfo;
VEC(tree) *vbases;
/* If there are no baseclasses, there is certainly no primary base. */
if (n_baseclasses == 0)
return;
/* First look for a dynamic direct non-virtual base. */
for (i = 0; BINFO_BASE_ITERATE (type_binfo, i, base_binfo); i++) for (i = 0; BINFO_BASE_ITERATE (type_binfo, i, base_binfo); i++)
{ {
tree basetype = BINFO_TYPE (base_binfo); tree basetype = BINFO_TYPE (base_binfo);
if (TYPE_CONTAINS_VPTR_P (basetype)) if (TYPE_CONTAINS_VPTR_P (basetype) && !BINFO_VIRTUAL_P (base_binfo))
{ {
/* We prefer a non-virtual base, although a virtual one will primary = base_binfo;
do. */ goto found;
if (BINFO_VIRTUAL_P (base_binfo))
continue;
if (!CLASSTYPE_HAS_PRIMARY_BASE_P (t))
set_primary_base (t, base_binfo);
} }
} }
if (!TYPE_VFIELD (t)) /* A "nearly-empty" virtual base class can be the primary base
CLASSTYPE_PRIMARY_BINFO (t) = NULL_TREE; class, if no non-virtual polymorphic base can be found. Look for
a nearly-empty virtual dynamic base that is not already a primary
/* Find the indirect primary bases - those virtual bases which are primary base of something in the heirarchy. If there is no such base,
bases of something else in this hierarchy. */ just pick the first nearly-empty virtual base. */
for (vbases = CLASSTYPE_VBASECLASSES (t), i = 0;
VEC_iterate (tree, vbases, i, vbase_binfo); i++)
{
unsigned j;
/* See if this virtual base is an indirect primary base. To be
so, it must be a primary base within the hierarchy of one of
our direct bases. */
for (j = 0; BINFO_BASE_ITERATE (type_binfo, j, base_binfo); j++)
{
unsigned k;
VEC (tree) *base_vbases;
tree base_vbase_binfo;
tree basetype = BINFO_TYPE (base_binfo);
for (base_vbases = CLASSTYPE_VBASECLASSES (basetype), k = 0; for (base_binfo = TREE_CHAIN (type_binfo); base_binfo;
VEC_iterate (tree, base_vbases, k, base_vbase_binfo); k++) base_binfo = TREE_CHAIN (base_binfo))
if (BINFO_VIRTUAL_P (base_binfo)
&& CLASSTYPE_NEARLY_EMPTY_P (BINFO_TYPE (base_binfo)))
{ {
if (BINFO_PRIMARY_P (base_vbase_binfo) if (!BINFO_PRIMARY_P (base_binfo))
&& same_type_p (BINFO_TYPE (base_vbase_binfo),
BINFO_TYPE (vbase_binfo)))
{ {
BINFO_INDIRECT_PRIMARY_P (vbase_binfo) = 1; /* Found one that is not primary. */
break; primary = base_binfo;
} goto found;
}
/* If we've discovered that this virtual base is an indirect
primary base, then we can move on to the next virtual
base. */
if (BINFO_INDIRECT_PRIMARY_P (vbase_binfo))
break;
} }
else if (!primary)
/* Remember the first candidate. */
primary = base_binfo;
} }
/* A "nearly-empty" virtual base class can be the primary base found:
class, if no non-virtual polymorphic base can be found. */ /* If we've got a primary base, use it. */
if (!CLASSTYPE_HAS_PRIMARY_BASE_P (t)) if (primary)
{ {
/* If not NULL, this is the best primary base candidate we have tree basetype = BINFO_TYPE (primary);
found so far. */
tree candidate = NULL_TREE;
tree base_binfo;
/* Loop over the baseclasses. */ CLASSTYPE_PRIMARY_BINFO (t) = primary;
for (base_binfo = TYPE_BINFO (t); if (BINFO_PRIMARY_P (primary))
base_binfo; /* We are stealing a primary base. */
base_binfo = TREE_CHAIN (base_binfo)) BINFO_LOST_PRIMARY_P (BINFO_INHERITANCE_CHAIN (primary)) = 1;
BINFO_PRIMARY_P (primary) = 1;
if (BINFO_VIRTUAL_P (primary))
{ {
tree basetype = BINFO_TYPE (base_binfo); tree delta;
if (BINFO_VIRTUAL_P (base_binfo) BINFO_INHERITANCE_CHAIN (primary) = type_binfo;
&& CLASSTYPE_NEARLY_EMPTY_P (basetype)) /* A virtual binfo might have been copied from within
{ another hierarchy. As we're about to use it as a primary
/* If this is not an indirect primary base, then it's base, make sure the offsets match. */
definitely our primary base. */ delta = size_diffop (ssize_int (0),
if (!BINFO_INDIRECT_PRIMARY_P (base_binfo)) convert (ssizetype, BINFO_OFFSET (primary)));
{
candidate = base_binfo;
break;
}
/* If this is an indirect primary base, it still could be propagate_binfo_offsets (primary, delta);
our primary base -- unless we later find there's another
nearly-empty virtual base that isn't an indirect
primary base. */
if (!candidate)
candidate = base_binfo;
}
} }
/* If we've got a primary base, use it. */ primary = TYPE_BINFO (basetype);
if (candidate)
set_primary_base (t, candidate);
}
/* Mark the primary base classes at this point. */ TYPE_VFIELD (t) = TYPE_VFIELD (basetype);
mark_primary_bases (t); BINFO_VTABLE (type_binfo) = BINFO_VTABLE (primary);
BINFO_VIRTUALS (type_binfo) = BINFO_VIRTUALS (primary);
}
} }
/* Set memoizing fields and bits of T (and its variants) for later /* Set memoizing fields and bits of T (and its variants) for later
...@@ -3324,7 +3278,8 @@ walk_subobject_offsets (tree type, ...@@ -3324,7 +3278,8 @@ walk_subobject_offsets (tree type,
tree vbase = get_primary_binfo (type_binfo); tree vbase = get_primary_binfo (type_binfo);
if (vbase && BINFO_VIRTUAL_P (vbase) if (vbase && BINFO_VIRTUAL_P (vbase)
&& BINFO_PRIMARY_BASE_OF (vbase) == type_binfo) && BINFO_PRIMARY_P (vbase)
&& BINFO_INHERITANCE_CHAIN (vbase) == type_binfo)
{ {
r = (walk_subobject_offsets r = (walk_subobject_offsets
(vbase, f, offset, (vbase, f, offset,
...@@ -4346,7 +4301,7 @@ propagate_binfo_offsets (tree binfo, tree offset) ...@@ -4346,7 +4301,7 @@ propagate_binfo_offsets (tree binfo, tree offset)
/* Find the primary base class. */ /* Find the primary base class. */
primary_binfo = get_primary_binfo (binfo); primary_binfo = get_primary_binfo (binfo);
if (primary_binfo && BINFO_PRIMARY_BASE_OF (primary_binfo) == binfo) if (primary_binfo && BINFO_INHERITANCE_CHAIN (primary_binfo) == binfo)
propagate_binfo_offsets (primary_binfo, offset); propagate_binfo_offsets (primary_binfo, offset);
/* Scan all of the bases, pushing the BINFO_OFFSET adjust /* Scan all of the bases, pushing the BINFO_OFFSET adjust
...@@ -4478,7 +4433,8 @@ end_of_class (tree t, int include_virtuals_p) ...@@ -4478,7 +4433,8 @@ end_of_class (tree t, int include_virtuals_p)
{ {
if (!include_virtuals_p if (!include_virtuals_p
&& BINFO_VIRTUAL_P (base_binfo) && BINFO_VIRTUAL_P (base_binfo)
&& BINFO_PRIMARY_BASE_OF (base_binfo) != TYPE_BINFO (t)) && (!BINFO_PRIMARY_P (base_binfo)
|| BINFO_INHERITANCE_CHAIN (base_binfo) != TYPE_BINFO (t)))
continue; continue;
offset = end_of_base (base_binfo); offset = end_of_base (base_binfo);
...@@ -4620,9 +4576,8 @@ layout_class_type (tree t, tree *virtuals_p) ...@@ -4620,9 +4576,8 @@ layout_class_type (tree t, tree *virtuals_p)
/* Start laying out the record. */ /* Start laying out the record. */
rli = start_record_layout (t); rli = start_record_layout (t);
/* If possible, we reuse the virtual function table pointer from one /* Mark all the primary bases in the hierarchy. */
of our base classes. */ determine_primary_bases (t);
determine_primary_base (t);
/* Create a pointer to our virtual function table. */ /* Create a pointer to our virtual function table. */
vptr = create_vtable_ptr (t, virtuals_p); vptr = create_vtable_ptr (t, virtuals_p);
...@@ -6452,7 +6407,7 @@ dump_class_hierarchy_r (FILE *stream, ...@@ -6452,7 +6407,7 @@ dump_class_hierarchy_r (FILE *stream,
indented = maybe_indent_hierarchy (stream, indent, 0); indented = maybe_indent_hierarchy (stream, indent, 0);
fprintf (stream, "%s (0x%lx) ", fprintf (stream, "%s (0x%lx) ",
type_as_string (binfo, TFF_PLAIN_IDENTIFIER), type_as_string (BINFO_TYPE (binfo), TFF_PLAIN_IDENTIFIER),
(unsigned long) binfo); (unsigned long) binfo);
if (binfo != igo) if (binfo != igo)
{ {
...@@ -6472,13 +6427,13 @@ dump_class_hierarchy_r (FILE *stream, ...@@ -6472,13 +6427,13 @@ dump_class_hierarchy_r (FILE *stream,
fprintf (stream, "\n"); fprintf (stream, "\n");
indented = 0; indented = 0;
if (BINFO_PRIMARY_BASE_OF (binfo)) if (BINFO_PRIMARY_P (binfo))
{ {
indented = maybe_indent_hierarchy (stream, indent + 3, indented); indented = maybe_indent_hierarchy (stream, indent + 3, indented);
fprintf (stream, " primary-for %s (0x%lx)", fprintf (stream, " primary-for %s (0x%lx)",
type_as_string (BINFO_PRIMARY_BASE_OF (binfo), type_as_string (BINFO_TYPE (BINFO_INHERITANCE_CHAIN (binfo)),
TFF_PLAIN_IDENTIFIER), TFF_PLAIN_IDENTIFIER),
(unsigned long)BINFO_PRIMARY_BASE_OF (binfo)); (unsigned long)BINFO_INHERITANCE_CHAIN (binfo));
} }
if (BINFO_LOST_PRIMARY_P (binfo)) if (BINFO_LOST_PRIMARY_P (binfo))
{ {
...@@ -6607,7 +6562,7 @@ dump_vtable (tree t, tree binfo, tree vtable) ...@@ -6607,7 +6562,7 @@ dump_vtable (tree t, tree binfo, tree vtable)
fprintf (stream, "%s for %s", fprintf (stream, "%s for %s",
ctor_vtbl_p ? "Construction vtable" : "Vtable", ctor_vtbl_p ? "Construction vtable" : "Vtable",
type_as_string (binfo, TFF_PLAIN_IDENTIFIER)); type_as_string (BINFO_TYPE (binfo), TFF_PLAIN_IDENTIFIER));
if (ctor_vtbl_p) if (ctor_vtbl_p)
{ {
if (!BINFO_VIRTUAL_P (binfo)) if (!BINFO_VIRTUAL_P (binfo))
...@@ -6962,8 +6917,8 @@ dfs_build_secondary_vptr_vtt_inits (tree binfo, void *data) ...@@ -6962,8 +6917,8 @@ dfs_build_secondary_vptr_vtt_inits (tree binfo, void *data)
/* It's a primary virtual base, and this is not the construction /* It's a primary virtual base, and this is not the construction
vtable. Find the base this is primary of in the inheritance graph, vtable. Find the base this is primary of in the inheritance graph,
and use that base's vtable now. */ and use that base's vtable now. */
while (BINFO_PRIMARY_BASE_OF (binfo)) while (BINFO_PRIMARY_P (binfo))
binfo = BINFO_PRIMARY_BASE_OF (binfo); binfo = BINFO_INHERITANCE_CHAIN (binfo);
} }
init = binfo_ctor_vtable (binfo); init = binfo_ctor_vtable (binfo);
TREE_VALUE (l) = tree_cons (NULL_TREE, init, TREE_VALUE (l)); TREE_VALUE (l) = tree_cons (NULL_TREE, init, TREE_VALUE (l));
...@@ -7155,23 +7110,25 @@ dfs_accumulate_vtbl_inits (tree binfo, ...@@ -7155,23 +7110,25 @@ dfs_accumulate_vtbl_inits (tree binfo,
RTTI_BINFO. RTTI_BINFO.
3) We are primary to something not a base of RTTI_BINFO. */ 3) We are primary to something not a base of RTTI_BINFO. */
tree b = BINFO_PRIMARY_BASE_OF (binfo); tree b;
tree last = NULL_TREE; tree last = NULL_TREE;
/* First, look through the bases we are primary to for RTTI_BINFO /* First, look through the bases we are primary to for RTTI_BINFO
or a virtual base. */ or a virtual base. */
for (; b; b = BINFO_PRIMARY_BASE_OF (b)) b = binfo;
while (BINFO_PRIMARY_P (b))
{ {
b = BINFO_INHERITANCE_CHAIN (b);
last = b; last = b;
if (BINFO_VIRTUAL_P (b) || b == rtti_binfo) if (BINFO_VIRTUAL_P (b) || b == rtti_binfo)
break; goto found;
} }
/* If we run out of primary links, keep looking down our /* If we run out of primary links, keep looking down our
inheritance chain; we might be an indirect primary. */ inheritance chain; we might be an indirect primary. */
if (b == NULL_TREE)
for (b = last; b; b = BINFO_INHERITANCE_CHAIN (b)) for (b = last; b; b = BINFO_INHERITANCE_CHAIN (b))
if (BINFO_VIRTUAL_P (b) || b == rtti_binfo) if (BINFO_VIRTUAL_P (b) || b == rtti_binfo)
break; break;
found:
/* If we found RTTI_BINFO, this is case 1. If we found a virtual /* If we found RTTI_BINFO, this is case 1. If we found a virtual
base B and it is a base of RTTI_BINFO, this is case 2. In base B and it is a base of RTTI_BINFO, this is case 2. In
...@@ -7790,7 +7747,8 @@ build_rtti_vtbl_entries (tree binfo, vtbl_init_data* vid) ...@@ -7790,7 +7747,8 @@ build_rtti_vtbl_entries (tree binfo, vtbl_init_data* vid)
tree primary_base; tree primary_base;
primary_base = get_primary_binfo (b); primary_base = get_primary_binfo (b);
gcc_assert (BINFO_PRIMARY_BASE_OF (primary_base) == b); gcc_assert (BINFO_PRIMARY_P (primary_base)
&& BINFO_INHERITANCE_CHAIN (primary_base) == b);
b = primary_base; b = primary_base;
} }
offset = size_diffop (BINFO_OFFSET (vid->rtti_binfo), BINFO_OFFSET (b)); offset = size_diffop (BINFO_OFFSET (vid->rtti_binfo), BINFO_OFFSET (b));
......
...@@ -1405,14 +1405,6 @@ struct lang_type GTY(()) ...@@ -1405,14 +1405,6 @@ struct lang_type GTY(())
/* Additional macros for inheritance information. */ /* Additional macros for inheritance information. */
/* The BINFO_INHERITANCE_CHAIN is used opposite to the description in
gcc/tree.h. In particular if D is non-virtually derived from B
then the BINFO for B (in D) will have a BINFO_INHERITANCE_CHAIN
pointing to D. If D is virtually derived, its
BINFO_INHERITANCE_CHAIN will point to the most derived binfo. In
tree.h, this pointer is described as pointing in other
direction. The binfos of virtual bases are shared. */
/* Nonzero means that this class is on a path leading to a new vtable. */ /* Nonzero means that this class is on a path leading to a new vtable. */
#define BINFO_VTABLE_PATH_MARKED(NODE) BINFO_FLAG_1 (NODE) #define BINFO_VTABLE_PATH_MARKED(NODE) BINFO_FLAG_1 (NODE)
...@@ -1428,11 +1420,6 @@ struct lang_type GTY(()) ...@@ -1428,11 +1420,6 @@ struct lang_type GTY(())
gcc_assert (!BINFO_PRIMARY_P (B) || BINFO_VIRTUAL_P (B)), \ gcc_assert (!BINFO_PRIMARY_P (B) || BINFO_VIRTUAL_P (B)), \
gcc_assert (TYPE_VFIELD (BINFO_TYPE (B)))) gcc_assert (TYPE_VFIELD (BINFO_TYPE (B))))
/* Nonzero if this BINFO is a primary base class. */
#define BINFO_PRIMARY_P(NODE) \
(BINFO_PRIMARY_BASE_OF (NODE) != NULL_TREE)
/* Nonzero if this binfo is for a dependent base - one that should not /* Nonzero if this binfo is for a dependent base - one that should not
be searched. */ be searched. */
#define BINFO_DEPENDENT_BASE_P(NODE) BINFO_FLAG_3 (NODE) #define BINFO_DEPENDENT_BASE_P(NODE) BINFO_FLAG_3 (NODE)
...@@ -1442,10 +1429,8 @@ struct lang_type GTY(()) ...@@ -1442,10 +1429,8 @@ struct lang_type GTY(())
base in the complete hierarchy. */ base in the complete hierarchy. */
#define BINFO_LOST_PRIMARY_P(NODE) BINFO_FLAG_4 (NODE) #define BINFO_LOST_PRIMARY_P(NODE) BINFO_FLAG_4 (NODE)
/* Nonzero if this binfo is an indirect primary base, i.e. a virtual /* Nonzero if this BINFO is a primary base class. */
base that is a primary base of some of other class in the #define BINFO_PRIMARY_P(NODE) BINFO_FLAG_5(NODE)
hierarchy. */
#define BINFO_INDIRECT_PRIMARY_P(NODE) BINFO_FLAG_5 (NODE)
/* Used by various search routines. */ /* Used by various search routines. */
#define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE) #define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE)
......
...@@ -716,15 +716,14 @@ build_vtbl_address (tree binfo) ...@@ -716,15 +716,14 @@ build_vtbl_address (tree binfo)
tree binfo_for = binfo; tree binfo_for = binfo;
tree vtbl; tree vtbl;
if (BINFO_VPTR_INDEX (binfo) && BINFO_VIRTUAL_P (binfo) if (BINFO_VPTR_INDEX (binfo) && BINFO_VIRTUAL_P (binfo))
&& BINFO_PRIMARY_P (binfo))
/* If this is a virtual primary base, then the vtable we want to store /* If this is a virtual primary base, then the vtable we want to store
is that for the base this is being used as the primary base of. We is that for the base this is being used as the primary base of. We
can't simply skip the initialization, because we may be expanding the can't simply skip the initialization, because we may be expanding the
inits of a subobject constructor where the virtual base layout inits of a subobject constructor where the virtual base layout
can be different. */ can be different. */
while (BINFO_PRIMARY_BASE_OF (binfo_for)) while (BINFO_PRIMARY_P (binfo_for))
binfo_for = BINFO_PRIMARY_BASE_OF (binfo_for); binfo_for = BINFO_INHERITANCE_CHAIN (binfo_for);
/* Figure out what vtable BINFO's vtable is based on, and mark it as /* Figure out what vtable BINFO's vtable is based on, and mark it as
used. */ used. */
......
...@@ -1706,15 +1706,10 @@ struct tree_type GTY(()) ...@@ -1706,15 +1706,10 @@ struct tree_type GTY(())
found. NULL_TREE if there is no secondary vptr in the VTT. */ found. NULL_TREE if there is no secondary vptr in the VTT. */
#define BINFO_VPTR_INDEX(NODE) (TREE_BINFO_CHECK(NODE)->binfo.vtt_vptr) #define BINFO_VPTR_INDEX(NODE) (TREE_BINFO_CHECK(NODE)->binfo.vtt_vptr)
/* The binfo of which NODE is a primary base. (This is different from
BINFO_INHERITANCE_CHAIN for virtual base because a virtual base is
sometimes a primary base for a class for which it is not an
immediate base.) */
#define BINFO_PRIMARY_BASE_OF(NODE) (TREE_BINFO_CHECK(NODE)->binfo.primary)
/* The BINFO_INHERITANCE_CHAIN points at the binfo for the base /* The BINFO_INHERITANCE_CHAIN points at the binfo for the base
inheriting this base for non-virtual bases. For virtual bases it inheriting this base for non-virtual bases. For virtual bases it
points to the binfo of the most derived type. */ points either to the binfo for which this is a primary binfo, or to
the binfo of the most derived type. */
#define BINFO_INHERITANCE_CHAIN(NODE) \ #define BINFO_INHERITANCE_CHAIN(NODE) \
(TREE_BINFO_CHECK(NODE)->binfo.inheritance) (TREE_BINFO_CHECK(NODE)->binfo.inheritance)
...@@ -1731,7 +1726,6 @@ struct tree_binfo GTY (()) ...@@ -1731,7 +1726,6 @@ struct tree_binfo GTY (())
tree vtt_subvtt; tree vtt_subvtt;
tree vtt_vptr; tree vtt_vptr;
tree primary;
VEC(tree) base_binfos; VEC(tree) base_binfos;
}; };
......
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