aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2004-07-20 12:26:02 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2004-07-20 12:26:02 +0000
commitfa743e8cda25ba09a4731a3443df9e0e56e87581 (patch)
treed4f6d97c6ff518d744dc34b2b6c955e9348bb0b0 /gcc/cp
parent35ae2ed81410448471c46f7757e6bc879d4de250 (diff)
downloadgcc-fa743e8cda25ba09a4731a3443df9e0e56e87581.zip
gcc-fa743e8cda25ba09a4731a3443df9e0e56e87581.tar.gz
gcc-fa743e8cda25ba09a4731a3443df9e0e56e87581.tar.bz2
tree.h: Include vec.h
.: * tree.h: Include vec.h (DEF_VEC_P(tree)): New type. (BINFO_BASE_BINFOS, BINFO_N_BASE_BINFOS, BINFO_BASE_BINFO): Adjust. (BINFO_BASE_APPEND, BINFO_BASE_ITERATE): New. (BINFO_LANG_SLOT): Remove. (BINFO_SUBVTT_INDEX, BINFO_VPTR_INDEX, BINFO_PRIMARY_BASE_OF): New. (struct tree_binfo): Turn base_binfos into a trailing VEC(tree). Add vtt_subvtt, vtt_vptr, primary fields. (binfo_lang_slots): Remove. * tree.c (binfo_lang_slots): Remove. (make_tree_binfo_stat): Take a base binfo count, not a lang slot count. Adjust. * Makefile.in (TREE_H): Add vec.h * alias.c (record_component_aliases): Adjust BINFO access. * dbxout.c (dbxout_type): Likewise. * dwarf2out.c (gen_member_die): Likewise. * sdbout.c (sdbout_one_type): Likewise. * tree-dump.c (deque_and_dump): Likewise. * config/i386/i386.c (classify_argument, contains_128bit_aligned_vector_p): Likewise. * config/sh/symbian.c (symbian_export_vtable_and_rtti_p): Likewise. * doc/c-tree.texi (Classes): Update BINFO documentation. cp: * cp-tree.h (DEF_VEC_P(tree)): Remove here. (BINFO_SUBVTT_INDEX, BINFO_VPTR_INDEX, BINFO_PRIMARY_BASE_OF): Moved to common. (BINFO_LANG_SLOTS): Remove. * tree.c (copy_binfo): Adjust BINFO creation and accessors. * decl.c (xref_basetypes): Adjust BINFO creation and accessors. * class.c (check_bases): Adjust BINFO accessors. (determine_primary_base, finish_struct_bits, maybe_warn_about_overly_private_class, warn_hidden, walk_subobject_offsets, propagate_binfo_offsets, end_of_class, warn_about_ambiguous_bases, get_vfield_name, dump_class_hierarchy_r, build_vtt_inits, accumulate_vtbl_inits, add_vcall_offset_vtbl_entries_r): Likewise. * dump.c (cp_dump_tree): Likewise. * init.c (sort_mem_initializers, expand_member_init, build_delete, push_base_cleanups): Likewise. * method.c (do_build_copy_constructor, do_build_assign_ref, synthesize_exception_spec): Likewise. name-lookup.c (arg_assoc_class): Likewise. * pt.c (instantiate_class_template, get_template_base_recursive): Likewise. * rtti.c (get_pseudo_ti_init, get_pseudo_ti_desc): Likewise. * typeck2.c (process_init_constructor): Likewise. * search.c (lookup_base_r, dynamic_cast_base_recurse, dfs_access_in_type, dfs_walk_real, look_for_overrides, types_overlap_p, copied_binfo, original_binfo): Likewise. (binfo_for_vtable): Remove java: * class.c (add_interface_do): Remove. (set_super_info, interface_of_p, maybe_add_interface, add_interface, make_class_data, layout_class, add_miranda_methods): Adjust BINFO accessors and addition. * expr.c (can_widen_reference_to, lookup_field): Adjust BINFO accessors. * jcf-write.c (generate_classfile): Likewise. * parse.y (patch_anonymous_class, check_inner_circular_reference, check_circular_reference, java_complete_class, check_abstract_method_definitions, java_check_abstract_method_definitions, check_interface_throws_clauses, java_check_abstract_methods, lookup_java_interface_method2, find_applicable_accessible_methods_list): Adjust BINFO accessors and addition. * typeck.c (find_method_in_interfaces): Adjust BINFO accessors. From-SVN: r84949
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog30
-rw-r--r--gcc/cp/class.c123
-rw-r--r--gcc/cp/cp-tree.h20
-rw-r--r--gcc/cp/decl.c28
-rw-r--r--gcc/cp/dump.c6
-rw-r--r--gcc/cp/init.c36
-rw-r--r--gcc/cp/method.c36
-rw-r--r--gcc/cp/name-lookup.c14
-rw-r--r--gcc/cp/pt.c28
-rw-r--r--gcc/cp/rtti.c11
-rw-r--r--gcc/cp/search.c137
-rw-r--r--gcc/cp/tree.c19
-rw-r--r--gcc/cp/typeck2.c2
13 files changed, 195 insertions, 295 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0a038fc..5ff48d0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,33 @@
+2004-07-20 Nathan Sidwell <nathan@codesourcery.com>
+
+ * cp-tree.h (DEF_VEC_P(tree)): Remove here.
+ (BINFO_SUBVTT_INDEX, BINFO_VPTR_INDEX, BINFO_PRIMARY_BASE_OF):
+ Moved to common.
+ (BINFO_LANG_SLOTS): Remove.
+ * tree.c (copy_binfo): Adjust BINFO creation and accessors.
+ * decl.c (xref_basetypes): Adjust BINFO creation and accessors.
+ * class.c (check_bases): Adjust BINFO accessors.
+ (determine_primary_base, finish_struct_bits,
+ maybe_warn_about_overly_private_class, warn_hidden,
+ walk_subobject_offsets, propagate_binfo_offsets, end_of_class,
+ warn_about_ambiguous_bases, get_vfield_name,
+ dump_class_hierarchy_r, build_vtt_inits, accumulate_vtbl_inits,
+ add_vcall_offset_vtbl_entries_r): Likewise.
+ * dump.c (cp_dump_tree): Likewise.
+ * init.c (sort_mem_initializers, expand_member_init, build_delete,
+ push_base_cleanups): Likewise.
+ * method.c (do_build_copy_constructor, do_build_assign_ref,
+ synthesize_exception_spec): Likewise.
+ name-lookup.c (arg_assoc_class): Likewise.
+ * pt.c (instantiate_class_template,
+ get_template_base_recursive): Likewise.
+ * rtti.c (get_pseudo_ti_init, get_pseudo_ti_desc): Likewise.
+ * typeck2.c (process_init_constructor): Likewise.
+ * search.c (lookup_base_r, dynamic_cast_base_recurse,
+ dfs_access_in_type, dfs_walk_real, look_for_overrides,
+ types_overlap_p, copied_binfo, original_binfo): Likewise.
+ (binfo_for_vtable): Remove
+
2004-07-20 Steven Bosscher <stevenb@suse.de>
* cp-tree.h (struct lang_decl_flags): Unify the template_info and
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 69f6d9e..70374eb 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1130,23 +1130,17 @@ check_bases (tree t,
int* cant_have_const_ctor_p,
int* no_const_asn_ref_p)
{
- int n_baseclasses;
int i;
int seen_non_virtual_nearly_empty_base_p;
- tree binfos;
+ tree base_binfo;
+ tree binfo;
- binfos = BINFO_BASE_BINFOS (TYPE_BINFO (t));
- n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t));
seen_non_virtual_nearly_empty_base_p = 0;
- for (i = 0; i < n_baseclasses; ++i)
+ for (binfo = TYPE_BINFO (t), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree base_binfo;
- tree basetype;
-
- /* Figure out what base we're looking at. */
- base_binfo = TREE_VEC_ELT (binfos, i);
- basetype = TREE_TYPE (base_binfo);
+ tree basetype = TREE_TYPE (base_binfo);
my_friendly_assert (COMPLETE_TYPE_P (basetype), 20040714);
@@ -1269,17 +1263,15 @@ 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;
- type_binfo = TYPE_BINFO (t);
-
- for (i = 0; i < n_baseclasses; i++)
+ for (i = 0; BINFO_BASE_ITERATE (type_binfo, i, base_binfo); i++)
{
- tree base_binfo = BINFO_BASE_BINFO (type_binfo, i);
tree basetype = BINFO_TYPE (base_binfo);
if (TYPE_CONTAINS_VPTR_P (basetype))
@@ -1325,12 +1317,12 @@ determine_primary_base (tree t)
/* 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; j != n_baseclasses; ++j)
+ 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 (BINFO_BASE_BINFO (TYPE_BINFO (t), j));
+ tree basetype = BINFO_TYPE (base_binfo);
for (base_vbases = CLASSTYPE_VBASECLASSES (basetype), k = 0;
VEC_iterate (tree, base_vbases, k, base_vbase_binfo); k++)
@@ -1407,7 +1399,6 @@ determine_primary_base (tree t)
static void
finish_struct_bits (tree t)
{
- int n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t));
tree variants;
/* Fix up variants (if any). */
@@ -1439,7 +1430,7 @@ finish_struct_bits (tree t)
TYPE_SIZE_UNIT (variants) = TYPE_SIZE_UNIT (t);
}
- if (n_baseclasses && TYPE_POLYMORPHIC_P (t))
+ if (BINFO_N_BASE_BINFOS (TYPE_BINFO (t)) && TYPE_POLYMORPHIC_P (t))
/* For a class w/o baseclasses, `finish_struct' has set
CLASS_TYPE_ABSTRACT_VIRTUALS correctly (by definition).
Similarly for a class whose base classes do not have vtables.
@@ -1537,10 +1528,10 @@ maybe_warn_about_overly_private_class (tree t)
constructors/destructors we want to use the code below that
issues error messages specifically referring to
constructors/destructors.) */
- int i;
+ unsigned i;
tree binfo = TYPE_BINFO (t);
- for (i = 0; i < BINFO_N_BASE_BINFOS (binfo); i++)
+ for (i = 0; i != BINFO_N_BASE_BINFOS (binfo); i++)
if (BINFO_BASE_ACCESS (binfo, i) != access_private_node)
{
has_nonprivate_method = 1;
@@ -2370,6 +2361,8 @@ warn_hidden (tree t)
tree name;
tree fndecl;
tree base_fndecls;
+ tree base_binfo;
+ tree binfo;
int j;
/* All functions in this slot in the CLASSTYPE_METHOD_VEC will
@@ -2379,9 +2372,10 @@ warn_hidden (tree t)
base_fndecls = NULL_TREE;
/* Iterate through all of the base classes looking for possibly
hidden functions. */
- for (j = 0; j < BINFO_N_BASE_BINFOS (TYPE_BINFO (t)); j++)
+ for (binfo = TYPE_BINFO (t), j = 0;
+ BINFO_BASE_ITERATE (binfo, j, base_binfo); j++)
{
- tree basetype = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (t), j));
+ tree basetype = BINFO_TYPE (base_binfo);
base_fndecls = chainon (get_basefndecls (name, basetype),
base_fndecls);
}
@@ -3178,12 +3172,10 @@ walk_subobject_offsets (tree type,
/* Iterate through the direct base classes of TYPE. */
if (!type_binfo)
type_binfo = TYPE_BINFO (type);
- for (i = 0; i < BINFO_N_BASE_BINFOS (type_binfo); ++i)
+ for (i = 0; BINFO_BASE_ITERATE (type_binfo, i, binfo); i++)
{
tree binfo_offset;
- binfo = BINFO_BASE_BINFO (type_binfo, i);
-
if (abi_version_at_least (2)
&& BINFO_VIRTUAL_P (binfo))
continue;
@@ -4263,6 +4255,7 @@ propagate_binfo_offsets (tree binfo, tree offset)
{
int i;
tree primary_binfo;
+ tree base_binfo;
/* Update BINFO's offset. */
BINFO_OFFSET (binfo)
@@ -4279,10 +4272,8 @@ propagate_binfo_offsets (tree binfo, tree offset)
/* Scan all of the bases, pushing the BINFO_OFFSET adjust
downwards. */
- for (i = 0; i < BINFO_N_BASE_BINFOS (binfo); ++i)
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
{
- tree base_binfo = BINFO_BASE_BINFO (binfo, i);
-
/* Don't do the primary base twice. */
if (base_binfo == primary_binfo)
continue;
@@ -4403,16 +4394,15 @@ end_of_class (tree t, int include_virtuals_p)
tree offset;
int i;
- for (i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (t)); ++i)
+ for (binfo = TYPE_BINFO (t), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
{
- binfo = BINFO_BASE_BINFO (TYPE_BINFO (t), i);
-
if (!include_virtuals_p
- && BINFO_VIRTUAL_P (binfo)
- && BINFO_PRIMARY_BASE_OF (binfo) != TYPE_BINFO (t))
+ && BINFO_VIRTUAL_P (base_binfo)
+ && BINFO_PRIMARY_BASE_OF (base_binfo) != TYPE_BINFO (t))
continue;
- offset = end_of_base (binfo);
+ offset = end_of_base (base_binfo);
if (INT_CST_LT_UNSIGNED (result, offset))
result = offset;
}
@@ -4447,12 +4437,13 @@ warn_about_ambiguous_bases (tree t)
VEC (tree) *vbases;
tree basetype;
tree binfo;
+ tree base_binfo;
/* Check direct bases. */
- for (i = 0;
- i < BINFO_N_BASE_BINFOS (TYPE_BINFO (t)); ++i)
+ for (binfo = TYPE_BINFO (t), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
{
- basetype = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (t), i));
+ basetype = BINFO_TYPE (base_binfo);
if (!lookup_base (t, basetype, ba_ignore | ba_quiet, NULL))
warning ("direct base `%T' inaccessible in `%T' due to ambiguity",
@@ -6142,7 +6133,7 @@ get_vfield_name (tree type)
char *buf;
for (binfo = TYPE_BINFO (type);
- BINFO_BASE_BINFOS (binfo);
+ BINFO_N_BASE_BINFOS (binfo);
binfo = base_binfo)
{
base_binfo = BINFO_BASE_BINFO (binfo, 0);
@@ -6231,11 +6222,13 @@ contains_empty_class_p (tree type)
if (CLASS_TYPE_P (type))
{
tree field;
+ tree binfo;
+ tree base_binfo;
int i;
- for (i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (type)); ++i)
- if (contains_empty_class_p
- (BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (type), i))))
+ for (binfo = TYPE_BINFO (type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
+ if (contains_empty_class_p (BINFO_TYPE (base_binfo)))
return true;
for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
if (TREE_CODE (field) == FIELD_DECL
@@ -6401,7 +6394,8 @@ dump_class_hierarchy_r (FILE *stream,
int indent)
{
int indented = 0;
- tree base_binfos;
+ tree base_binfo;
+ int i;
indented = maybe_indent_hierarchy (stream, indent, 0);
fprintf (stream, "%s (0x%lx) ",
@@ -6477,21 +6471,9 @@ dump_class_hierarchy_r (FILE *stream,
if (indented)
fprintf (stream, "\n");
}
-
- base_binfos = BINFO_BASE_BINFOS (binfo);
- if (base_binfos)
- {
- int ix, n;
-
- n = TREE_VEC_LENGTH (base_binfos);
- for (ix = 0; ix != n; ix++)
- {
- tree base_binfo = TREE_VEC_ELT (base_binfos, ix);
- igo = dump_class_hierarchy_r (stream, flags, base_binfo,
- igo, indent + 2);
- }
- }
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ igo = dump_class_hierarchy_r (stream, flags, base_binfo, igo, indent + 2);
return igo;
}
@@ -6820,13 +6802,9 @@ build_vtt_inits (tree binfo, tree t, tree* inits, tree* index)
*index = size_binop (PLUS_EXPR, *index, TYPE_SIZE_UNIT (ptr_type_node));
/* Recursively add the secondary VTTs for non-virtual bases. */
- for (i = 0; i < BINFO_N_BASE_BINFOS (binfo); ++i)
- {
- b = BINFO_BASE_BINFO (binfo, i);
- if (!BINFO_VIRTUAL_P (b))
- inits = build_vtt_inits (BINFO_BASE_BINFO (binfo, i), t,
- inits, index);
- }
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, b); ++i)
+ if (!BINFO_VIRTUAL_P (b))
+ inits = build_vtt_inits (BINFO_BASE_BINFO (binfo, i), t, inits, index);
/* Add secondary virtual pointers for all subobjects of BINFO with
either virtual bases or reachable along a virtual path, except
@@ -7058,6 +7036,7 @@ accumulate_vtbl_inits (tree binfo,
tree inits)
{
int i;
+ tree base_binfo;
int ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t);
my_friendly_assert (same_type_p (BINFO_TYPE (binfo),
@@ -7086,10 +7065,8 @@ accumulate_vtbl_inits (tree binfo,
secondary vtable lies from the primary vtable. We can't use
dfs_walk here because we need to iterate through bases of BINFO
and RTTI_BINFO simultaneously. */
- for (i = 0; i < BINFO_N_BASE_BINFOS (binfo); ++i)
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
{
- tree base_binfo = BINFO_BASE_BINFO (binfo, i);
-
/* Skip virtual bases. */
if (BINFO_VIRTUAL_P (base_binfo))
continue;
@@ -7562,6 +7539,7 @@ add_vcall_offset_vtbl_entries_r (tree binfo, vtbl_init_data* vid)
{
int i;
tree primary_binfo;
+ tree base_binfo;
/* Don't walk into virtual bases -- except, of course, for the
virtual base for which we are building vcall offsets. Any
@@ -7579,14 +7557,9 @@ add_vcall_offset_vtbl_entries_r (tree binfo, vtbl_init_data* vid)
add_vcall_offset_vtbl_entries_1 (binfo, vid);
/* Scan the non-primary bases of BINFO. */
- for (i = 0; i < BINFO_N_BASE_BINFOS (binfo); ++i)
- {
- tree base_binfo;
-
- base_binfo = BINFO_BASE_BINFO (binfo, i);
- if (base_binfo != primary_binfo)
- add_vcall_offset_vtbl_entries_r (base_binfo, vid);
- }
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
+ if (base_binfo != primary_binfo)
+ add_vcall_offset_vtbl_entries_r (base_binfo, vid);
}
/* Called from build_vcall_offset_vtbl_entries_r. */
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 4b717de..b3867bb 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -937,8 +937,6 @@ struct lang_type_header GTY(())
BOOL_BITFIELD has_const_assign_ref : 1;
};
-DEF_VEC_P (tree);
-
/* This structure provides additional information above and beyond
what is provide in the ordinary tree_type. In the past, we used it
for the types of class types, template parameters types, typename
@@ -1397,24 +1395,6 @@ struct lang_type GTY(())
#define BINFO_PRIMARY_P(NODE) \
(BINFO_PRIMARY_BASE_OF (NODE) != NULL_TREE)
-/* The index in the VTT where this subobject's sub-VTT can be found.
- NULL_TREE if there is no sub-VTT. */
-#define BINFO_SUBVTT_INDEX(NODE) BINFO_LANG_SLOT(NODE, 0)
-
-/* The index in the VTT where the vptr for this subobject can be
- found. NULL_TREE if there is no secondary vptr in the VTT. */
-#define BINFO_VPTR_INDEX(NODE) BINFO_LANG_SLOT(NODE, 1)
-
-/* 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) BINFO_LANG_SLOT(NODE, 2)
-
-/* C++ binfos have 3 additional entries. */
-
-#define BINFO_LANG_SLOTS (3)
-
/* Nonzero if this binfo is for a dependent base - one that should not
be searched. */
#define BINFO_DEPENDENT_BASE_P(NODE) BINFO_FLAG_3 (NODE)
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 2d4fa89..8dee86a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9032,7 +9032,7 @@ void
xref_basetypes (tree ref, tree base_list)
{
tree *basep;
- tree binfo;
+ tree binfo, base_binfo;
unsigned max_vbases = 0; /* Maxium direct & indirect virtual bases. */
unsigned max_bases = 0; /* Maxium direct bases. */
int i;
@@ -9079,14 +9079,13 @@ xref_basetypes (tree ref, tree base_list)
my_friendly_assert (!TYPE_BINFO (ref) || TYPE_SIZE (ref), 20040706);
my_friendly_assert (TYPE_MAIN_VARIANT (ref) == ref, 20040712);
- binfo = make_tree_binfo (BINFO_LANG_SLOTS);
+ binfo = make_tree_binfo (max_bases);
TYPE_BINFO (ref) = binfo;
BINFO_OFFSET (binfo) = size_zero_node;
BINFO_TYPE (binfo) = ref;
if (max_bases)
{
- BINFO_BASE_BINFOS (binfo) = make_tree_vec (max_bases);
BINFO_BASE_ACCESSES (binfo) = make_tree_vec (max_bases);
/* An aggregate cannot have baseclasses. */
CLASSTYPE_NON_AGGREGATE (ref) = 1;
@@ -9118,13 +9117,11 @@ xref_basetypes (tree ref, tree base_list)
error ("Java class '%T' cannot have virtual bases", ref);
}
- i = 0;
for (igo_prev = binfo; base_list; base_list = TREE_CHAIN (base_list))
{
tree access = TREE_PURPOSE (base_list);
int via_virtual = TREE_TYPE (base_list) != NULL_TREE;
tree basetype = TREE_VALUE (base_list);
- tree base_binfo = NULL_TREE;
if (access == access_default_node)
access = default_access;
@@ -9154,6 +9151,7 @@ xref_basetypes (tree ref, tree base_list)
if (TYPE_FOR_JAVA (basetype) && (current_lang_depth () == 0))
TYPE_FOR_JAVA (ref) = 1;
+ base_binfo = NULL_TREE;
if (CLASS_TYPE_P (basetype) && !dependent_type_p (basetype))
{
base_binfo = TYPE_BINFO (basetype);
@@ -9178,22 +9176,20 @@ xref_basetypes (tree ref, tree base_list)
if (!BINFO_INHERITANCE_CHAIN (base_binfo))
BINFO_INHERITANCE_CHAIN (base_binfo) = binfo;
- TREE_VEC_ELT (BINFO_BASE_ACCESSES (binfo), i) = access;
- BINFO_BASE_BINFO (binfo, i) = base_binfo;
- i++;
+ TREE_VEC_ELT (BINFO_BASE_ACCESSES (binfo),
+ BINFO_N_BASE_BINFOS (binfo)) = access;
+ BINFO_BASE_APPEND (binfo, base_binfo);
}
if (max_bases)
- {
- /* If any bases were invalid, we will have allocated too many
- slots. */
- TREE_VEC_LENGTH (BINFO_BASE_ACCESSES (binfo)) = i;
- TREE_VEC_LENGTH (BINFO_BASE_BINFOS (binfo)) = i;
- }
+ /* If any bases were invalid, we will have allocated too many
+ slots. */
+ TREE_VEC_LENGTH (BINFO_BASE_ACCESSES (binfo))
+ = BINFO_N_BASE_BINFOS (binfo);
/* Unmark all the types. */
- for (i = 0; i != BINFO_N_BASE_BINFOS (binfo); i++)
- CLEAR_CLASSTYPE_MARKED (BINFO_TYPE (BINFO_BASE_BINFO (binfo, i)));
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ CLEAR_CLASSTYPE_MARKED (BINFO_TYPE (base_binfo));
CLEAR_CLASSTYPE_MARKED (ref);
}
diff --git a/gcc/cp/dump.c b/gcc/cp/dump.c
index 1669a96..ce136af 100644
--- a/gcc/cp/dump.c
+++ b/gcc/cp/dump.c
@@ -267,10 +267,12 @@ cp_dump_tree (void* dump_info, tree t)
if (!dump_flag (di, TDF_SLIM, t) && TYPE_BINFO (t))
{
int i;
+ tree binfo;
+ tree base_binfo;
- for (i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (t)); ++i)
+ for (binfo = TYPE_BINFO (t), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
{
- tree base_binfo = BINFO_BASE_BINFO (TYPE_BINFO (t), i);
dump_child ("base", BINFO_TYPE (base_binfo));
if (BINFO_VIRTUAL_P (base_binfo))
dump_string (di, "virtual");
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 988bfba..99df1b6 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -457,7 +457,7 @@ static tree
sort_mem_initializers (tree t, tree mem_inits)
{
tree init;
- tree base;
+ tree base, binfo, base_binfo;
tree sorted_inits;
tree next_subobject;
VEC (tree) *vbases;
@@ -476,12 +476,11 @@ sort_mem_initializers (tree t, tree mem_inits)
sorted_inits = tree_cons (base, NULL_TREE, sorted_inits);
/* Process the direct bases. */
- for (i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (t)); ++i)
- {
- base = BINFO_BASE_BINFO (TYPE_BINFO (t), i);
- if (!BINFO_VIRTUAL_P (base))
- sorted_inits = tree_cons (base, NULL_TREE, sorted_inits);
- }
+ for (binfo = TYPE_BINFO (t), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
+ if (!BINFO_VIRTUAL_P (base_binfo))
+ sorted_inits = tree_cons (base_binfo, NULL_TREE, sorted_inits);
+
/* Process the non-static data members. */
sorted_inits = build_field_list (t, sorted_inits, &uses_unions_p);
/* Reverse the entire list of initializations, so that they are in
@@ -983,14 +982,10 @@ expand_member_init (tree name)
virtual_binfo = NULL_TREE;
/* Look for a direct base. */
- for (i = 0; i < BINFO_N_BASE_BINFOS (class_binfo); ++i)
- if (same_type_p
- (basetype, BINFO_TYPE
- (BINFO_BASE_BINFO (TYPE_BINFO (current_class_type), i))))
- {
- direct_binfo = BINFO_BASE_BINFO (class_binfo, i);
- break;
- }
+ for (i = 0; BINFO_BASE_ITERATE (class_binfo, i, direct_binfo); ++i)
+ if (same_type_p (basetype, BINFO_TYPE (direct_binfo)))
+ break;
+
/* Look for a virtual base -- unless the direct base is itself
virtual. */
if (!direct_binfo || !BINFO_VIRTUAL_P (direct_binfo))
@@ -2858,8 +2853,8 @@ build_delete (tree type, tree addr, special_function_kind auto_delete,
void
push_base_cleanups (void)
{
- tree binfos, base_binfo;
- int i, n_baseclasses;
+ tree binfo, base_binfo;
+ int i;
tree member;
tree expr;
VEC (tree) *vbases;
@@ -2892,13 +2887,10 @@ push_base_cleanups (void)
}
}
- binfos = BINFO_BASE_BINFOS (TYPE_BINFO (current_class_type));
- n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (current_class_type));
-
/* Take care of the remaining baseclasses. */
- for (i = 0; i < n_baseclasses; i++)
+ for (binfo = TYPE_BINFO (current_class_type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree base_binfo = TREE_VEC_ELT (binfos, i);
if (TYPE_HAS_TRIVIAL_DESTRUCTOR (BINFO_TYPE (base_binfo))
|| BINFO_VIRTUAL_P (base_binfo))
continue;
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 802d4c0..a28c901 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -515,12 +515,10 @@ do_build_copy_constructor (tree fndecl)
else
{
tree fields = TYPE_FIELDS (current_class_type);
- int n_bases = BINFO_N_BASE_BINFOS (TYPE_BINFO (current_class_type));
- tree binfos = BINFO_BASE_BINFOS (TYPE_BINFO (current_class_type));
tree member_init_list = NULL_TREE;
int cvquals = cp_type_quals (TREE_TYPE (parm));
int i;
- tree binfo;
+ tree binfo, base_binfo;
VEC (tree) *vbases;
/* Initialize all the base-classes with the parameter converted
@@ -539,17 +537,17 @@ do_build_copy_constructor (tree fndecl)
member_init_list);
}
- for (i = 0; i < n_bases; ++i)
+ for (binfo = TYPE_BINFO (current_class_type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree binfo = TREE_VEC_ELT (binfos, i);
- if (BINFO_VIRTUAL_P (binfo))
+ if (BINFO_VIRTUAL_P (base_binfo))
continue;
member_init_list
- = tree_cons (binfo,
+ = tree_cons (base_binfo,
build_tree_list (NULL_TREE,
build_base_path (PLUS_EXPR, parm,
- binfo, 1)),
+ base_binfo, 1)),
member_init_list);
}
@@ -617,26 +615,24 @@ do_build_assign_ref (tree fndecl)
tree fields;
int cvquals = cp_type_quals (TREE_TYPE (parm));
int i;
+ tree binfo, base_binfo;
/* Assign to each of the direct base classes. */
- for (i = 0;
- i < BINFO_N_BASE_BINFOS (TYPE_BINFO (current_class_type));
- ++i)
+ for (binfo = TYPE_BINFO (current_class_type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree binfo;
tree converted_parm;
- binfo = BINFO_BASE_BINFO (TYPE_BINFO (current_class_type), i);
/* We must convert PARM directly to the base class
explicitly since the base class may be ambiguous. */
- converted_parm = build_base_path (PLUS_EXPR, parm, binfo, 1);
+ converted_parm = build_base_path (PLUS_EXPR, parm, base_binfo, 1);
/* Call the base class assignment operator. */
finish_expr_stmt
(build_special_member_call (current_class_ref,
ansi_assopname (NOP_EXPR),
build_tree_list (NULL_TREE,
converted_parm),
- binfo,
+ base_binfo,
LOOKUP_NORMAL | LOOKUP_NONVIRTUAL));
}
@@ -783,13 +779,13 @@ synthesize_exception_spec (tree type, tree (*extractor) (tree, void*),
{
tree raises = empty_except_spec;
tree fields = TYPE_FIELDS (type);
- int i, n_bases = BINFO_N_BASE_BINFOS (TYPE_BINFO (type));
- tree binfos = BINFO_BASE_BINFOS (TYPE_BINFO (type));
+ tree binfo, base_binfo;
+ int i;
- for (i = 0; i != n_bases; i++)
+ for (binfo = TYPE_BINFO (type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree base = BINFO_TYPE (TREE_VEC_ELT (binfos, i));
- tree fn = (*extractor) (base, client);
+ tree fn = (*extractor) (BINFO_TYPE (base_binfo), client);
if (fn)
{
tree fn_raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn));
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 6cbebb3..ffb03ea 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -4400,11 +4400,15 @@ arg_assoc_class (struct arg_lookup *k, tree type)
return true;
if (TYPE_BINFO (type))
- /* Process baseclasses. */
- for (i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (type)); i++)
- if (arg_assoc_class
- (k, BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (type), i))))
- return true;
+ {
+ /* Process baseclasses. */
+ tree binfo, base_binfo;
+
+ for (binfo = TYPE_BINFO (type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ if (arg_assoc_class (k, BINFO_TYPE (base_binfo)))
+ return true;
+ }
/* Process friends. */
for (list = DECL_FRIENDLIST (TYPE_MAIN_DECL (type)); list;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4c059c1..76769ef 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5416,10 +5416,9 @@ instantiate_class_template (tree type)
#endif
base_list = NULL_TREE;
- if (BINFO_BASE_BINFOS (pbinfo))
+ if (BINFO_N_BASE_BINFOS (pbinfo))
{
- tree pbases = BINFO_BASE_BINFOS (pbinfo);
- tree paccesses = BINFO_BASE_ACCESSES (pbinfo);
+ tree pbase_binfo;
tree context = TYPE_CONTEXT (type);
bool pop_p;
int i;
@@ -5431,22 +5430,18 @@ instantiate_class_template (tree type)
/* Substitute into each of the bases to determine the actual
basetypes. */
- for (i = 0; i < TREE_VEC_LENGTH (pbases); ++i)
+ for (i = 0; BINFO_BASE_ITERATE (pbinfo, i, pbase_binfo); i++)
{
tree base;
- tree access;
- tree pbase;
-
- pbase = TREE_VEC_ELT (pbases, i);
- access = TREE_VEC_ELT (paccesses, i);
+ tree access = BINFO_BASE_ACCESS (pbinfo, i);
/* Substitute to figure out the base class. */
- base = tsubst (BINFO_TYPE (pbase), args, tf_error, NULL_TREE);
+ base = tsubst (BINFO_TYPE (pbase_binfo), args, tf_error, NULL_TREE);
if (base == error_mark_node)
continue;
base_list = tree_cons (access, base, base_list);
- if (BINFO_VIRTUAL_P (pbase))
+ if (BINFO_VIRTUAL_P (pbase_binfo))
TREE_TYPE (base_list) = integer_type_node;
}
@@ -7421,6 +7416,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (ctx != DECL_CONTEXT (t))
return lookup_field (ctx, DECL_NAME (t), 0, false);
}
+
return t;
case VAR_DECL:
@@ -9366,8 +9362,8 @@ get_template_base_recursive (tree tparms,
tree rval,
int flags)
{
- tree binfos;
- int i, n_baselinks;
+ tree base_binfo;
+ int i;
tree arg = BINFO_TYPE (arg_binfo);
if (!(flags & GTB_IGNORE_TYPE))
@@ -9389,13 +9385,9 @@ get_template_base_recursive (tree tparms,
rval = r;
}
- binfos = BINFO_BASE_BINFOS (arg_binfo);
- n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
-
/* Process base types. */
- for (i = 0; i < n_baselinks; i++)
+ for (i = 0; BINFO_BASE_ITERATE (arg_binfo, i, base_binfo); i++)
{
- tree base_binfo = TREE_VEC_ELT (binfos, i);
int this_virtual;
/* Skip this base, if we've already seen it. */
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 71a7611..b1ae3dd 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -1032,8 +1032,7 @@ get_pseudo_ti_init (tree type, tree var_desc, bool *non_public_p)
}
else if (var_desc == si_class_desc_type_node)
{
- tree base_binfos = BINFO_BASE_BINFOS (TYPE_BINFO (type));
- tree base_binfo = TREE_VEC_ELT (base_binfos, 0);
+ tree base_binfo = BINFO_BASE_BINFO (TYPE_BINFO (type), 0);
tree tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo));
tree base_inits = tree_cons (NULL_TREE, tinfo, NULL_TREE);
@@ -1044,7 +1043,6 @@ get_pseudo_ti_init (tree type, tree var_desc, bool *non_public_p)
int hint = class_hint_flags (type);
tree binfo = TYPE_BINFO (type);
int nbases = BINFO_N_BASE_BINFOS (binfo);
- tree base_binfos = BINFO_BASE_BINFOS (binfo);
tree base_accesses = BINFO_BASE_ACCESSES (binfo);
tree base_inits = NULL_TREE;
int ix;
@@ -1052,7 +1050,7 @@ get_pseudo_ti_init (tree type, tree var_desc, bool *non_public_p)
/* Generate the base information initializer. */
for (ix = nbases; ix--;)
{
- tree base_binfo = TREE_VEC_ELT (base_binfos, ix);
+ tree base_binfo = BINFO_BASE_BINFO (binfo, ix);
tree base_init = NULL_TREE;
int flags = 0;
tree tinfo;
@@ -1192,10 +1190,9 @@ get_pseudo_ti_desc (tree type)
else
{
tree binfo = TYPE_BINFO (type);
- tree base_binfos = BINFO_BASE_BINFOS (binfo);
tree base_accesses = BINFO_BASE_ACCESSES (binfo);
- tree base_binfo = TREE_VEC_ELT (base_binfos, 0);
- int num_bases = TREE_VEC_LENGTH (base_binfos);
+ tree base_binfo = BINFO_BASE_BINFO (binfo, 0);
+ int num_bases = BINFO_N_BASE_BINFOS (binfo);
if (num_bases == 1
&& TREE_VEC_ELT (base_accesses, 0) == access_public_node
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index e172aa3..364e8f2 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -97,7 +97,7 @@ lookup_base_r (tree binfo, tree base, base_access access,
tree *binfo_ptr)
{
int i;
- tree bases, accesses;
+ tree base_binfo;
base_kind found = bk_not_base;
if (same_type_p (BINFO_TYPE (binfo), base))
@@ -123,14 +123,8 @@ lookup_base_r (tree binfo, tree base, base_access access,
return found;
}
- bases = BINFO_BASE_BINFOS (binfo);
- accesses = BINFO_BASE_ACCESSES (binfo);
- if (!bases)
- return bk_not_base;
-
- for (i = TREE_VEC_LENGTH (bases); i--;)
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree base_binfo = TREE_VEC_ELT (bases, i);
base_kind bk;
bk = lookup_base_r (base_binfo, base,
@@ -290,8 +284,9 @@ static int
dynamic_cast_base_recurse (tree subtype, tree binfo, bool is_via_virtual,
tree *offset_ptr)
{
- tree binfos, accesses;
- int i, n_baselinks;
+ tree accesses;
+ tree base_binfo;
+ int i;
int worst = -2;
if (BINFO_TYPE (binfo) == subtype)
@@ -305,12 +300,9 @@ dynamic_cast_base_recurse (tree subtype, tree binfo, bool is_via_virtual,
}
}
- binfos = BINFO_BASE_BINFOS (binfo);
accesses = BINFO_BASE_ACCESSES (binfo);
- n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
- for (i = 0; i < n_baselinks; i++)
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree base_binfo = TREE_VEC_ELT (binfos, i);
tree base_access = TREE_VEC_ELT (accesses, i);
int rval;
@@ -630,17 +622,13 @@ dfs_access_in_type (tree binfo, void *data)
if (!access)
{
int i;
- int n_baselinks;
- tree binfos, accesses;
+ tree base_binfo, accesses;
/* Otherwise, scan our baseclasses, and pick the most favorable
access. */
- binfos = BINFO_BASE_BINFOS (binfo);
accesses = BINFO_BASE_ACCESSES (binfo);
- n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
- for (i = 0; i < n_baselinks; ++i)
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree base_binfo = TREE_VEC_ELT (binfos, i);
tree base_access = TREE_VEC_ELT (accesses, i);
access_kind base_access_now = BINFO_ACCESS (base_binfo);
@@ -1601,6 +1589,8 @@ dfs_walk_real (tree binfo,
tree (*qfn) (tree, int, void *),
void *data)
{
+ int i;
+ tree base_binfo;
tree rval = NULL_TREE;
/* Call the pre-order walking function. */
@@ -1612,25 +1602,17 @@ dfs_walk_real (tree binfo,
}
/* Process the basetypes. */
- if (BINFO_BASE_BINFOS (binfo))
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- int i, n = TREE_VEC_LENGTH (BINFO_BASE_BINFOS (binfo));
- for (i = 0; i != n; i++)
+ if (qfn)
{
- tree base_binfo;
-
- if (qfn)
- base_binfo = (*qfn) (binfo, i, data);
- else
- base_binfo = BINFO_BASE_BINFO (binfo, i);
-
- if (base_binfo)
- {
- rval = dfs_walk_real (base_binfo, prefn, postfn, qfn, data);
- if (rval)
- return rval;
- }
+ base_binfo = (*qfn) (binfo, i, data);
+ if (!base_binfo)
+ continue;
}
+ rval = dfs_walk_real (base_binfo, prefn, postfn, qfn, data);
+ if (rval)
+ return rval;
}
/* Call the post-order walking function. */
@@ -1761,14 +1743,13 @@ int
look_for_overrides (tree type, tree fndecl)
{
tree binfo = TYPE_BINFO (type);
- tree basebinfos = BINFO_BASE_BINFOS (binfo);
- int nbasebinfos = basebinfos ? TREE_VEC_LENGTH (basebinfos) : 0;
+ tree base_binfo;
int ix;
int found = 0;
- for (ix = 0; ix != nbasebinfos; ix++)
+ for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
{
- tree basetype = BINFO_TYPE (TREE_VEC_ELT (basebinfos, ix));
+ tree basetype = BINFO_TYPE (base_binfo);
if (TYPE_POLYMORPHIC_P (basetype))
found += look_for_overrides_r (basetype, fndecl);
@@ -2161,7 +2142,7 @@ dfs_check_overlap (tree empty_binfo, void *data)
oi->found_overlap = 1;
break;
}
- else if (BINFO_BASE_BINFOS (binfo) == NULL_TREE)
+ else if (!BINFO_N_BASE_BINFOS (binfo))
break;
}
@@ -2196,34 +2177,6 @@ types_overlap_p (tree empty_type, tree next_type)
return oi.found_overlap;
}
-/* Given a vtable VAR, determine which of the inherited classes the vtable
- inherits (in a loose sense) functions from.
-
- FIXME: This does not work with the new ABI. */
-
-tree
-binfo_for_vtable (tree var)
-{
- tree main_binfo = TYPE_BINFO (DECL_CONTEXT (var));
- tree binfos = BINFO_BASE_BINFOS (TYPE_BINFO (BINFO_TYPE (main_binfo)));
- int n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (BINFO_TYPE (main_binfo)));
- int i;
-
- for (i = 0; i < n_baseclasses; i++)
- {
- tree base_binfo = TREE_VEC_ELT (binfos, i);
- if (base_binfo != NULL_TREE && BINFO_VTABLE (base_binfo) == var)
- return base_binfo;
- }
-
- /* If no secondary base classes matched, return the primary base, if
- there is one. */
- if (CLASSTYPE_HAS_PRIMARY_BASE_P (BINFO_TYPE (main_binfo)))
- return get_primary_binfo (main_binfo);
-
- return main_binfo;
-}
-
/* Returns the binfo of the first direct or indirect virtual base derived
from BINFO, or NULL if binfo is not via virtual. */
@@ -2275,22 +2228,17 @@ copied_binfo (tree binfo, tree here)
}
else if (BINFO_INHERITANCE_CHAIN (binfo))
{
- tree base_binfos;
- int ix, n;
+ tree cbinfo;
+ tree base_binfo;
+ int ix;
- base_binfos = copied_binfo (BINFO_INHERITANCE_CHAIN (binfo), here);
- base_binfos = BINFO_BASE_BINFOS (base_binfos);
- n = TREE_VEC_LENGTH (base_binfos);
- for (ix = 0; ix != n; ix++)
- {
- tree base = TREE_VEC_ELT (base_binfos, ix);
-
- if (BINFO_TYPE (base) == BINFO_TYPE (binfo))
- {
- result = base;
- break;
- }
- }
+ cbinfo = copied_binfo (BINFO_INHERITANCE_CHAIN (binfo), here);
+ for (ix = 0; BINFO_BASE_ITERATE (cbinfo, ix, base_binfo); ix++)
+ if (BINFO_TYPE (base_binfo) == BINFO_TYPE (binfo))
+ {
+ result = base_binfo;
+ break;
+ }
}
else
{
@@ -2339,20 +2287,15 @@ original_binfo (tree binfo, tree here)
base_binfos = original_binfo (BINFO_INHERITANCE_CHAIN (binfo), here);
if (base_binfos)
{
- int ix, n;
+ int ix;
+ tree base_binfo;
- base_binfos = BINFO_BASE_BINFOS (base_binfos);
- n = TREE_VEC_LENGTH (base_binfos);
- for (ix = 0; ix != n; ix++)
- {
- tree base = TREE_VEC_ELT (base_binfos, ix);
-
- if (BINFO_TYPE (base) == BINFO_TYPE (binfo))
- {
- result = base;
- break;
- }
- }
+ for (ix = 0; (base_binfo = BINFO_BASE_BINFO (base_binfos, ix)); ix++)
+ if (BINFO_TYPE (base_binfo) == BINFO_TYPE (binfo))
+ {
+ result = base_binfo;
+ break;
+ }
}
}
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index f334e72..f005d7c 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -597,7 +597,7 @@ copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt)
return new_binfo;
}
- new_binfo = make_tree_binfo (BINFO_LANG_SLOTS);
+ new_binfo = make_tree_binfo (binfo ? BINFO_N_BASE_BINFOS (binfo) : 0);
BINFO_TYPE (new_binfo) = type;
/* Chain it into the inheritance graph. */
@@ -606,7 +606,8 @@ copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt)
if (binfo)
{
- int ix, n = BINFO_N_BASE_BINFOS (binfo);
+ int ix;
+ tree base_binfo;
my_friendly_assert (!BINFO_DEPENDENT_BASE_P (binfo), 20040712);
my_friendly_assert (type == BINFO_TYPE (binfo), 20040714);
@@ -614,18 +615,12 @@ copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt)
BINFO_OFFSET (new_binfo) = BINFO_OFFSET (binfo);
BINFO_VIRTUALS (new_binfo) = BINFO_VIRTUALS (binfo);
- /* Create a new base binfo vector. */
- if (n)
- {
- BINFO_BASE_BINFOS (new_binfo) = make_tree_vec (n);
- /* We do not need to copy the accesses, as they are read only. */
- BINFO_BASE_ACCESSES (new_binfo) = BINFO_BASE_ACCESSES (binfo);
- }
+ /* We do not need to copy the accesses, as they are read only. */
+ BINFO_BASE_ACCESSES (new_binfo) = BINFO_BASE_ACCESSES (binfo);
/* Recursively copy base binfos of BINFO. */
- for (ix = 0; ix != n; ix++)
+ for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
{
- tree base_binfo = BINFO_BASE_BINFO (binfo, ix);
tree new_base_binfo;
my_friendly_assert (!BINFO_DEPENDENT_BASE_P (base_binfo), 20040713);
@@ -635,7 +630,7 @@ copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt)
if (!BINFO_INHERITANCE_CHAIN (new_base_binfo))
BINFO_INHERITANCE_CHAIN (new_base_binfo) = new_binfo;
- BINFO_BASE_BINFO (new_binfo, ix) = new_base_binfo;
+ BINFO_BASE_APPEND (new_binfo, new_base_binfo);
}
}
else
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 21bca00..53a5c18 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -954,7 +954,7 @@ process_init_constructor (tree type, tree init, tree* elts)
return error_mark_node;
}
- if (TYPE_BINFO (type) && BINFO_BASE_BINFOS (TYPE_BINFO (type)))
+ if (TYPE_BINFO (type) && BINFO_N_BASE_BINFOS (TYPE_BINFO (type)))
{
sorry ("initializer list for object of class with base classes");
return error_mark_node;