summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-20 12:26:02 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-20 12:26:02 +0000
commitf6cc6a0817157a9069e1989d975a08a7e299cb9f (patch)
treed4f6d97c6ff518d744dc34b2b6c955e9348bb0b0
parentf62ed60b214f15bdb21842816457e0a6ad09c056 (diff)
downloadgcc-f6cc6a0817157a9069e1989d975a08a7e299cb9f.tar.gz
.:
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84949 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog25
-rw-r--r--gcc/Makefile.in2
-rw-r--r--gcc/alias.c14
-rw-r--r--gcc/config/i386/i386.c43
-rw-r--r--gcc/config/sh/symbian.c20
-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
-rw-r--r--gcc/dbxout.c120
-rw-r--r--gcc/doc/c-tree.texi47
-rw-r--r--gcc/dwarf2out.c9
-rw-r--r--gcc/java/ChangeLog19
-rw-r--r--gcc/java/class.c141
-rw-r--r--gcc/java/expr.c26
-rw-r--r--gcc/java/jcf-write.c12
-rw-r--r--gcc/java/parse.y160
-rw-r--r--gcc/java/typeck.c11
-rw-r--r--gcc/sdbout.c14
-rw-r--r--gcc/tree-dump.c8
-rw-r--r--gcc/tree.c22
-rw-r--r--gcc/tree.h47
31 files changed, 556 insertions, 674 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fae5ace8b40..c788fc6164c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,28 @@
+2004-07-20 Nathan Sidwell <nathan@codesourcery.com>
+
+ * 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.
+
2004-07-20 Steven Bosscher <stevenb@suse.de>
* c-common.h (check_case_value): Remove prototype.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index f8acb48f5b2..8706bae3c72 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -686,7 +686,7 @@ RTL_BASE_H = rtl.h rtl.def $(MACHMODE_H)
RTL_H = $(RTL_BASE_H) genrtl.h input.h statistics.h
PARAMS_H = params.h params.def
TREE_H = tree.h tree.def $(MACHMODE_H) tree-check.h builtins.def \
- input.h statistics.h
+ input.h statistics.h vec.h
BASIC_BLOCK_H = basic-block.h bitmap.h sbitmap.h varray.h $(PARTITION_H) \
hard-reg-set.h cfghooks.h
COVERAGE_H = coverage.h gcov-io.h gcov-iov.h
diff --git a/gcc/alias.c b/gcc/alias.c
index 1bf1d757cb4..7200fff8adb 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -718,15 +718,15 @@ record_component_aliases (tree type)
case UNION_TYPE:
case QUAL_UNION_TYPE:
/* Recursively record aliases for the base classes, if there are any. */
- if (TYPE_BINFO (type) && BINFO_BASE_BINFOS (TYPE_BINFO (type)))
+ if (TYPE_BINFO (type))
{
int i;
- for (i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (type)); i++)
- {
- tree binfo = BINFO_BASE_BINFO (TYPE_BINFO (type), i);
- record_alias_subset (superset,
- get_alias_set (BINFO_TYPE (binfo)));
- }
+ tree binfo, base_binfo;
+
+ for (binfo = TYPE_BINFO (type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ record_alias_subset (superset,
+ get_alias_set (BINFO_TYPE (base_binfo)));
}
for (field = TYPE_FIELDS (type); field != 0; field = TREE_CHAIN (field))
if (TREE_CODE (field) == FIELD_DECL && ! DECL_NONADDRESSABLE_P (field))
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 86ea3890da8..95d0d527ff7 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2103,18 +2103,17 @@ classify_argument (enum machine_mode mode, tree type,
if (TREE_CODE (type) == RECORD_TYPE)
{
/* For classes first merge in the field of the subclasses. */
- if (TYPE_BINFO (type) && BINFO_BASE_BINFOS (TYPE_BINFO (type)))
+ if (TYPE_BINFO (type))
{
- tree bases = BINFO_BASE_BINFOS (TYPE_BINFO (type));
- int n_bases = BINFO_N_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 binfo = TREE_VEC_ELT (bases, i);
int num;
- int offset = tree_low_cst (BINFO_OFFSET (binfo), 0) * 8;
- tree type = BINFO_TYPE (binfo);
+ int offset = tree_low_cst (BINFO_OFFSET (base_binfo), 0) * 8;
+ tree type = BINFO_TYPE (base_binfo);
num = classify_argument (TYPE_MODE (type),
type, subclasses,
@@ -2191,18 +2190,17 @@ classify_argument (enum machine_mode mode, tree type,
|| TREE_CODE (type) == QUAL_UNION_TYPE)
{
/* For classes first merge in the field of the subclasses. */
- if (TYPE_BINFO (type) && BINFO_BASE_BINFOS (TYPE_BINFO (type)))
+ if (TYPE_BINFO (type))
{
- tree bases = BINFO_BASE_BINFOS (TYPE_BINFO (type));
- int n_bases = BINFO_N_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 binfo = TREE_VEC_ELT (bases, i);
int num;
- int offset = tree_low_cst (BINFO_OFFSET (binfo), 0) * 8;
- tree type = BINFO_TYPE (binfo);
+ int offset = tree_low_cst (BINFO_OFFSET (base_binfo), 0) * 8;
+ tree type = BINFO_TYPE (base_binfo);
num = classify_argument (TYPE_MODE (type),
type, subclasses,
@@ -2816,20 +2814,15 @@ contains_128bit_aligned_vector_p (tree type)
{
tree field;
- if (TYPE_BINFO (type) && BINFO_BASE_BINFOS (TYPE_BINFO (type)))
+ if (TYPE_BINFO (type))
{
- tree bases = BINFO_BASE_BINFOS (TYPE_BINFO (type));
- int n_bases = BINFO_N_BASE_BINFOS (TYPE_BINFO (type));
+ tree binfo, base_binfo;
int i;
- for (i = 0; i < n_bases; ++i)
- {
- tree binfo = TREE_VEC_ELT (bases, i);
- tree type = BINFO_TYPE (binfo);
-
- if (contains_128bit_aligned_vector_p (type))
- return true;
- }
+ for (binfo = TYPE_BINFO (type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ if (contains_128bit_aligned_vector_p (BINFO_TYPE (base_binfo)))
+ return true;
}
/* And now merge the fields of structure. */
for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
diff --git a/gcc/config/sh/symbian.c b/gcc/config/sh/symbian.c
index 33ab711ae2d..0469c54be4f 100644
--- a/gcc/config/sh/symbian.c
+++ b/gcc/config/sh/symbian.c
@@ -618,9 +618,10 @@ symbian_export_vtable_and_rtti_p (tree ctype)
bool inline_ctor_dtor;
bool dllimport_ctor_dtor;
bool dllimport_member;
- tree binfos;
+ tree binfo, base_binfo;
tree methods;
tree key;
+ int i;
int len;
/* Make sure that we are examining a class... */
@@ -729,20 +730,9 @@ symbian_export_vtable_and_rtti_p (tree ctype)
#endif
/* Now we must check and possibly export the base classes. */
- binfos = BINFO_BASE_BINFOS (TYPE_BINFO (ctype));
- len = BINFO_N_BASE_BINFOS (TYPE_BINFO (ctype));
-
- for (; len --;)
- {
- tree base_binfo;
- tree basetype;
-
- /* Figure out which base we're looking at. */
- base_binfo = TREE_VEC_ELT (binfos, len);
- basetype = TREE_TYPE (base_binfo);
-
- symbian_possibly_export_base_class (basetype);
- }
+ for (i = 0, binfo = TYPE_BINFO (ctype);
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ symbian_possibly_export_base_class (BINFO_TYPE (base_binfo));
return true;
}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0a038fc88dd..5ff48d0a3b8 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 69f6d9e6e6f..70374eb9e7b 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 4b717de85f9..b3867bb57fb 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 2d4fa895b50..8dee86aff14 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 1669a96bbd7..ce136afb5bf 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 988bfba1cd0..99df1b6f357 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 802d4c023fe..a28c90182c2 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 6cbebb3abba..ffb03eac64c 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 4c059c11805..76769ef00a1 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 71a7611f712..b1ae3dda80f 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 e172aa38553..364e8f26b77 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 f334e721ecc..f005d7c4f7d 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 21bca0025dd..53a5c186ff8 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;
diff --git a/gcc/dbxout.c b/gcc/dbxout.c
index aa863bda031..c888dd08875 100644
--- a/gcc/dbxout.c
+++ b/gcc/dbxout.c
@@ -1633,10 +1633,7 @@ dbxout_type (tree type, int full)
case UNION_TYPE:
case QUAL_UNION_TYPE:
{
- int i, n_baseclasses = 0;
-
- if (TYPE_BINFO (type) && BINFO_BASE_BINFOS (TYPE_BINFO (type)))
- n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (type));
+ tree binfo = TYPE_BINFO (type);
/* Output a structure type. We must use the same test here as we
use in the DBX_NO_XREFS case above. */
@@ -1683,65 +1680,72 @@ dbxout_type (tree type, int full)
CHARS (1);
print_wide_int (int_size_in_bytes (type));
- if (use_gnu_debug_info_extensions)
- {
- if (n_baseclasses)
- {
- have_used_extensions = 1;
- fprintf (asmfile, "!%d,", n_baseclasses);
- CHARS (8);
- }
- }
- for (i = 0; i < n_baseclasses; i++)
+ if (binfo)
{
- tree binfo = TYPE_BINFO (type);
- tree child = BINFO_BASE_BINFO (binfo, i);
- tree access = (BINFO_BASE_ACCESSES (binfo)
- ? BINFO_BASE_ACCESS (binfo, i) : access_public_node);
-
+ int i;
+ tree child;
+
if (use_gnu_debug_info_extensions)
{
- have_used_extensions = 1;
- putc (BINFO_VIRTUAL_P (child) ? '1' : '0', asmfile);
- putc (access == access_public_node ? '2' :
- (access == access_protected_node ? '1' :'0'),
- asmfile);
- CHARS (2);
- if (BINFO_VIRTUAL_P (child)
- && strcmp (lang_hooks.name, "GNU C++") == 0)
- /* For a virtual base, print the (negative) offset within
- the vtable where we must look to find the necessary
- adjustment. */
- print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
- * BITS_PER_UNIT);
- else
- print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
- * BITS_PER_UNIT);
- putc (',', asmfile);
- CHARS (1);
- dbxout_type (BINFO_TYPE (child), 0);
- putc (';', asmfile);
- CHARS (1);
+ if (BINFO_N_BASE_BINFOS (binfo))
+ {
+ have_used_extensions = 1;
+ fprintf (asmfile, "!%d,", BINFO_N_BASE_BINFOS (binfo));
+ CHARS (8);
+ }
}
- else
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, child); i++)
{
- /* Print out the base class information with fields
- which have the same names at the types they hold. */
- dbxout_type_name (BINFO_TYPE (child));
- putc (':', asmfile);
- CHARS (1);
- dbxout_type (BINFO_TYPE (child), full);
- putc (',', asmfile);
- CHARS (1);
- print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
- * BITS_PER_UNIT);
- putc (',', asmfile);
- CHARS (1);
- print_wide_int (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child)),
- 0)
- * BITS_PER_UNIT);
- putc (';', asmfile);
- CHARS (1);
+ tree access = (BINFO_BASE_ACCESSES (binfo)
+ ? BINFO_BASE_ACCESS (binfo, i)
+ : access_public_node);
+
+ if (use_gnu_debug_info_extensions)
+ {
+ have_used_extensions = 1;
+ putc (BINFO_VIRTUAL_P (child) ? '1' : '0', asmfile);
+ putc (access == access_public_node ? '2' :
+ (access == access_protected_node ? '1' :'0'),
+ asmfile);
+ CHARS (2);
+ if (BINFO_VIRTUAL_P (child)
+ && strcmp (lang_hooks.name, "GNU C++") == 0)
+ /* For a virtual base, print the (negative)
+ offset within the vtable where we must look
+ to find the necessary adjustment. */
+ print_wide_int
+ (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
+ * BITS_PER_UNIT);
+ else
+ print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
+ * BITS_PER_UNIT);
+ putc (',', asmfile);
+ CHARS (1);
+ dbxout_type (BINFO_TYPE (child), 0);
+ putc (';', asmfile);
+ CHARS (1);
+ }
+ else
+ {
+ /* Print out the base class information with
+ fields which have the same names at the types
+ they hold. */
+ dbxout_type_name (BINFO_TYPE (child));
+ putc (':', asmfile);
+ CHARS (1);
+ dbxout_type (BINFO_TYPE (child), full);
+ putc (',', asmfile);
+ CHARS (1);
+ print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
+ * BITS_PER_UNIT);
+ putc (',', asmfile);
+ CHARS (1);
+ print_wide_int
+ (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child)), 0)
+ * BITS_PER_UNIT);
+ putc (';', asmfile);
+ CHARS (1);
+ }
}
}
}
diff --git a/gcc/doc/c-tree.texi b/gcc/doc/c-tree.texi
index f25c8fb006a..f9509e44c6e 100644
--- a/gcc/doc/c-tree.texi
+++ b/gcc/doc/c-tree.texi
@@ -747,32 +747,33 @@ list. Implicitly declared functions (including default constructors,
copy constructors, assignment operators, and destructors) will appear on
this list as well.
-@c under reconstruction 2004-07-01, FIXME:Nathan Sidwell
-[Binfos are being redesigned, this information is in a state of flux.]
Every class has an associated @dfn{binfo}, which can be obtained with
@code{TYPE_BINFO}. Binfos are used to represent base-classes. The
binfo given by @code{TYPE_BINFO} is the degenerate case, whereby every
-class is considered to be its own base-class. The base classes for a
-particular binfo can be obtained with @code{BINFO_BASETYPES}. These
-base-classes are themselves binfos. The class type associated with a
-binfo is given by @code{BINFO_TYPE}. It is always the case that
-@code{BINFO_TYPE (TYPE_BINFO (x))} is the same type as @code{x}, up to
-qualifiers. However, it is not always the case that @code{TYPE_BINFO
-(BINFO_TYPE (y))} is always the same binfo as @code{y}. The reason is
-that if @code{y} is a binfo representing a base-class @code{B} of a
-derived class @code{D}, then @code{BINFO_TYPE (y)} will be @code{B},
-and @code{TYPE_BINFO (BINFO_TYPE (y))} will be @code{B} as its own
-base-class, rather than as a base-class of @code{D}.
-
-The @code{BINFO_BASETYPES} is a @code{TREE_VEC} (@pxref{Containers}).
-Base types appear in left-to-right order in this vector. You can tell
-whether or @code{public}, @code{protected}, or @code{private}
-inheritance was used by using the @code{TREE_VIA_PUBLIC},
-@code{TREE_VIA_PROTECTED}, and @code{TREE_VIA_PRIVATE} macros. Each of
-these macros takes a @code{BINFO} and is true if and only if the
-indicated kind of inheritance was used. If @code{TREE_VIA_VIRTUAL}
-holds of a binfo, then its @code{BINFO_TYPE} was inherited from
-virtually.
+class is considered to be its own base-class. The base binfos for a
+particular binfo are held in a vector, whose length is obtained with
+@code{BINFO_N_BASE_BINFOS}. The base binfos themselves are obtained
+with @code{BINFO_BASE_BINFO} and @code{BINFO_BASE_ITERATE}. To add a
+new binfo, use @code{BINFO_BASE_APPEND}. The vector of base binfos can
+be obtained with @code{BINFO_BASE_BINFOS}, but normally you do not need
+to use that. The class type associated with a binfo is given by
+@code{BINFO_TYPE}. It is not always the case that @code{BINFO_TYPE
+(TYPE_BINFO (x))}, because of typedefs and qualified types. Neither is
+it the case that @code{TYPE_BINFO (BINFO_TYPE (y))} is the same binfo as
+@code{y}. The reason is that if @code{y} is a binfo representing a
+base-class @code{B} of a derived class @code{D}, then @code{BINFO_TYPE
+(y)} will be @code{B}, and @code{TYPE_BINFO (BINFO_TYPE (y))} will be
+@code{B} as its own base-class, rather than as a base-class of @code{D}.
+
+The access to a base type can be found with @code{BINFO_BASE_ACCESS}.
+This will produce @code{access_public_node}, @code{access_private_node}
+or @code{access_protected_node}. If bases are always public,
+@code{BINFO_BASE_ACCESSES} may be @code{NULL}.
+
+@code{BINFO_VIRTUAL_P} is used to specify whether the binfo is inherited
+virtually or not. The other flags, @code{BINFO_MARKED_P} and
+@code{BINFO_FLAG_1} to @code{BINFO_FLAG_6} can be used for language
+specific use.
The following macros can be used on a tree node representing a class-type.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index a3014ccc01a..736f31cd401 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -11891,15 +11891,14 @@ gen_member_die (tree type, dw_die_ref context_die)
the TREE node representing the appropriate (containing) type. */
/* First output info about the base classes. */
- if (binfo && BINFO_BASE_BINFOS (binfo))
+ if (binfo)
{
- tree bases = BINFO_BASE_BINFOS (binfo);
tree accesses = BINFO_BASE_ACCESSES (binfo);
- int n_bases = TREE_VEC_LENGTH (bases);
int i;
+ tree base;
- for (i = 0; i < n_bases; i++)
- gen_inheritance_die (TREE_VEC_ELT (bases, i),
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base); i++)
+ gen_inheritance_die (base,
(accesses ? TREE_VEC_ELT (accesses, i)
: access_public_node), context_die);
}
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 308aaa36935..b2322fdb95c 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,22 @@
+2004-07-20 Nathan Sidwell <nathan@codesourcery.com>
+
+ * 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.
+
2004-07-18 Roger Sayle <roger@eyesopen.com>
* builtins.c (max_builtin, min_builtin,
diff --git a/gcc/java/class.c b/gcc/java/class.c
index 64e44090f40..82ae8224c79 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -57,7 +57,6 @@ static tree make_field_value (tree);
static tree get_dispatch_vector (tree);
static tree get_dispatch_table (tree, tree);
static int supers_all_compiled (tree type);
-static void add_interface_do (tree, tree, int);
static tree maybe_layout_super_class (tree, tree);
static void add_miranda_methods (tree, tree);
static int assume_compiled (const char *);
@@ -476,16 +475,14 @@ set_super_info (int access_flags, tree this_class,
if (super_class)
total_supers++;
- TYPE_BINFO (this_class) = make_tree_binfo (0);
+ TYPE_BINFO (this_class) = make_tree_binfo (total_supers);
TYPE_VFIELD (this_class) = TYPE_VFIELD (object_type_node);
- BINFO_BASE_BINFOS (TYPE_BINFO (this_class)) = make_tree_vec (total_supers);
if (super_class)
{
tree super_binfo = make_tree_binfo (0);
BINFO_TYPE (super_binfo) = super_class;
BINFO_OFFSET (super_binfo) = integer_zero_node;
- TREE_VEC_ELT (BINFO_BASE_BINFOS (TYPE_BINFO (this_class)), 0)
- = super_binfo;
+ BINFO_BASE_APPEND (TYPE_BINFO (this_class), super_binfo);
CLASS_HAS_SUPER_FLAG (TYPE_BINFO (this_class)) = 1;
}
@@ -530,26 +527,23 @@ class_depth (tree clas)
int
interface_of_p (tree type1, tree type2)
{
- int n, i;
- tree basetype_vec;
+ int i;
+ tree binfo, base_binfo;
if (! TYPE_BINFO (type2))
return 0;
- basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (type2));
- n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 0; i < n; i++)
- {
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
- if (vec_elt && BINFO_TYPE (vec_elt) == type1)
- return 1;
- }
- for (i = 0; i < n; i++)
- {
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
- if (vec_elt && BINFO_TYPE (vec_elt)
- && interface_of_p (type1, BINFO_TYPE (vec_elt)))
- return 1;
- }
+
+ for (binfo = TYPE_BINFO (type2), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ if (BINFO_TYPE (base_binfo) == type1)
+ return 1;
+
+ for (binfo = TYPE_BINFO (type2), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) /* */
+ if (BINFO_TYPE (base_binfo)
+ && interface_of_p (type1, BINFO_TYPE (base_binfo)))
+ return 1;
+
return 0;
}
@@ -636,17 +630,6 @@ common_enclosing_instance_p (tree type1, tree type2)
return 0;
}
-static void
-add_interface_do (tree basetype_vec, tree interface_class, int i)
-{
- tree interface_binfo = make_tree_binfo (0);
- BINFO_TYPE (interface_binfo) = interface_class;
- BINFO_OFFSET (interface_binfo) = integer_zero_node;
- BINFO_VPTR_FIELD (interface_binfo) = integer_zero_node;
- BINFO_VIRTUAL_P (interface_binfo) = 1;
- TREE_VEC_ELT (basetype_vec, i) = interface_binfo;
-}
-
/* Add INTERFACE_CLASS to THIS_CLASS iff INTERFACE_CLASS can't be
found in THIS_CLASS. Returns NULL_TREE upon success, INTERFACE_CLASS
if attempt is made to add it twice. */
@@ -654,22 +637,14 @@ add_interface_do (tree basetype_vec, tree interface_class, int i)
tree
maybe_add_interface (tree this_class, tree interface_class)
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (this_class));
+ tree binfo, base_binfo;
int i;
- int n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 0; ; i++)
- {
- if (i >= n)
- {
- error ("internal error - too many interface type");
- return NULL_TREE;
- }
- else if (TREE_VEC_ELT (basetype_vec, i) == NULL_TREE)
- break;
- else if (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)) == interface_class)
- return interface_class;
- }
- add_interface_do (basetype_vec, interface_class, i);
+
+ for (binfo = TYPE_BINFO (this_class), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ if (BINFO_TYPE (base_binfo) == interface_class)
+ return interface_class;
+ add_interface (this_class, interface_class);
return NULL_TREE;
}
@@ -678,20 +653,14 @@ maybe_add_interface (tree this_class, tree interface_class)
void
add_interface (tree this_class, tree interface_class)
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (this_class));
- int i;
- int n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 0; ; i++)
- {
- if (i >= n)
- {
- error ("internal error - too many interface type");
- return;
- }
- else if (TREE_VEC_ELT (basetype_vec, i) == NULL_TREE)
- break;
- }
- add_interface_do (basetype_vec, interface_class, i);
+ tree interface_binfo = make_tree_binfo (0);
+
+ BINFO_TYPE (interface_binfo) = interface_class;
+ BINFO_OFFSET (interface_binfo) = integer_zero_node;
+ BINFO_VPTR_FIELD (interface_binfo) = integer_zero_node;
+ BINFO_VIRTUAL_P (interface_binfo) = 1;
+
+ BINFO_BASE_APPEND (TYPE_BINFO (this_class), interface_binfo);
}
#if 0
@@ -1666,9 +1635,10 @@ make_class_data (tree type)
= build_prim_array_type (class_ptr_type, interface_len);
idecl = build_decl (VAR_DECL, mangled_classname ("_IF_", type),
interface_array_type);
+
for (i = interface_len; i > 0; i--)
{
- tree child = TREE_VEC_ELT (BINFO_BASE_BINFOS (TYPE_BINFO (type)), i);
+ tree child = BINFO_BASE_BINFO (TYPE_BINFO (type), i);
tree iclass = BINFO_TYPE (child);
tree index;
if (! flag_indirect_dispatch
@@ -2063,27 +2033,21 @@ layout_class (tree this_class)
of this itself. */
if (!CLASS_FROM_SOURCE_P (this_class))
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (this_class));
-
- if (basetype_vec)
+ int i;
+
+ for (i = BINFO_N_BASE_BINFOS (TYPE_BINFO (this_class)) - 1; i > 0; i--)
{
- int n = TREE_VEC_LENGTH (basetype_vec) - 1;
- int i;
- for (i = n; i > 0; i--)
+ tree binfo = BINFO_BASE_BINFO (TYPE_BINFO (this_class), i);
+ tree super_interface = BINFO_TYPE (binfo);
+ tree maybe_super_interface
+ = maybe_layout_super_class (super_interface, NULL_TREE);
+ if (maybe_super_interface == NULL
+ || TREE_CODE (TYPE_SIZE (maybe_super_interface)) == ERROR_MARK)
{
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
- tree super_interface = BINFO_TYPE (vec_elt);
-
- tree maybe_super_interface
- = maybe_layout_super_class (super_interface, NULL_TREE);
- if (maybe_super_interface == NULL
- || TREE_CODE (TYPE_SIZE (maybe_super_interface)) == ERROR_MARK)
- {
- TYPE_SIZE (this_class) = error_mark_node;
- CLASS_BEING_LAIDOUT (this_class) = 0;
- class_list = TREE_CHAIN (class_list);
- return;
- }
+ TYPE_SIZE (this_class) = error_mark_node;
+ CLASS_BEING_LAIDOUT (this_class) = 0;
+ class_list = TREE_CHAIN (class_list);
+ return;
}
}
}
@@ -2099,15 +2063,14 @@ layout_class (tree this_class)
static void
add_miranda_methods (tree base_class, tree search_class)
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (search_class));
- int i, n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 1; i < n; ++i)
+ tree binfo, base_binfo;
+ int i;
+
+ for (binfo = TYPE_BINFO (search_class), i = 1;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
tree method_decl;
- tree elt = TREE_VEC_ELT (basetype_vec, i);
- if (elt == NULL_TREE)
- break;
- elt = BINFO_TYPE (elt);
+ tree elt = BINFO_TYPE (base_binfo);
/* Ensure that interface methods are seen in declared order. */
layout_class_methods (elt);
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index a6bc5759a63..228c1d16a4a 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -426,15 +426,16 @@ can_widen_reference_to (tree source_type, tree target_type)
{
/* target_type is OK if source_type or source_type ancestors
implement target_type. We handle multiple sub-interfaces */
+ tree binfo, base_binfo;
+ int i;
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (source_type));
- int n = TREE_VEC_LENGTH (basetype_vec), i;
- for (i=0 ; i < n; i++)
- if (can_widen_reference_to
- (TREE_TYPE (TREE_VEC_ELT (basetype_vec, i)),
- target_type))
+ for (binfo = TYPE_BINFO (source_type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ if (can_widen_reference_to
+ (BINFO_TYPE (base_binfo), target_type))
return 1;
- if (n == 0)
+
+ if (!i)
return 0;
}
@@ -1459,21 +1460,20 @@ lookup_field (tree *typep, tree name)
}
do
{
- tree field, basetype_vec;
+ tree field, binfo, base_binfo;
tree save_field;
- int n, i;
+ int i;
for (field = TYPE_FIELDS (*typep); field; field = TREE_CHAIN (field))
if (DECL_NAME (field) == name)
return field;
/* Process implemented interfaces. */
- basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (*typep));
- n = TREE_VEC_LENGTH (basetype_vec);
save_field = NULL_TREE;
- for (i = 0; i < n; i++)
+ for (binfo = TYPE_BINFO (*typep), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+ tree t = BINFO_TYPE (base_binfo);
if ((field = lookup_field (&t, name)))
{
if (save_field == field)
diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c
index a41c3554441..a73b7be83dc 100644
--- a/gcc/java/jcf-write.c
+++ b/gcc/java/jcf-write.c
@@ -2963,15 +2963,15 @@ generate_classfile (tree clas, struct jcf_partial *state)
}
else
{
- tree basetypes = BINFO_BASE_BINFOS (TYPE_BINFO (clas));
- tree base = BINFO_TYPE (TREE_VEC_ELT (basetypes, 0));
- int j = find_class_constant (&state->cpool, base);
+ tree binfo = TYPE_BINFO (clas);
+ tree base_binfo = BINFO_BASE_BINFO (binfo, 0);
+ int j = find_class_constant (&state->cpool, BINFO_TYPE (base_binfo));
+
PUT2 (j); /* super_class */
PUT2 (total_supers - 1); /* interfaces_count */
- for (i = 1; i < total_supers; i++)
+ for (i = 1; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- base = BINFO_TYPE (TREE_VEC_ELT (basetypes, i));
- j = find_class_constant (&state->cpool, base);
+ j = find_class_constant (&state->cpool, BINFO_TYPE (base_binfo));
PUT2 (j);
}
}
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 2ca09a2c33f..2f41b1b4f3a 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -3879,16 +3879,24 @@ patch_anonymous_class (tree type_decl, tree class_decl, tree wfl)
/* If it's an interface, implement it */
if (CLASS_INTERFACE (type_decl))
{
- tree s_binfo;
- int length;
-
if (parser_check_super_interface (type_decl, class_decl, wfl))
return;
- s_binfo = TREE_VEC_ELT (BINFO_BASE_BINFOS (TYPE_BINFO (class)), 0);
- length = TREE_VEC_LENGTH (BINFO_BASE_BINFOS (TYPE_BINFO (class)))+1;
- BINFO_BASE_BINFOS (TYPE_BINFO (class)) = make_tree_vec (length);
- TREE_VEC_ELT (BINFO_BASE_BINFOS (TYPE_BINFO (class)), 0) = s_binfo;
+ if (VEC_space (tree, BINFO_BASE_BINFOS (binfo), 1))
+ {
+ /* Extend the binfo - by reallocating and copying it. */
+ tree new_binfo;
+ tree base_binfo;
+ int i;
+
+ new_binfo = make_tree_binfo ((BINFO_N_BASE_BINFOS (binfo) + 1) * 2);
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ BINFO_BASE_APPEND (new_binfo, base_binfo);
+ CLASS_HAS_SUPER_FLAG (new_binfo) = CLASS_HAS_SUPER_FLAG (binfo);
+ BINFO_VTABLE (new_binfo) = BINFO_VTABLE (binfo);
+ TYPE_BINFO (class) = new_binfo;
+ }
+
/* And add the interface */
parser_add_interface (class_decl, type_decl, wfl);
}
@@ -3897,7 +3905,7 @@ patch_anonymous_class (tree type_decl, tree class_decl, tree wfl)
{
if (parser_check_super (type_decl, class_decl, wfl))
return;
- BINFO_TYPE (TREE_VEC_ELT (BINFO_BASE_BINFOS (binfo), 0)) = type;
+ BINFO_TYPE (BINFO_BASE_BINFO (binfo, 0)) = type;
}
}
@@ -5213,23 +5221,18 @@ register_incomplete_type (int kind, tree wfl, tree decl, tree ptr)
static tree
check_inner_circular_reference (tree source, tree target)
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (source));
+ tree base_binfo;
tree ctx, cl;
int i;
- if (!basetype_vec)
- return NULL_TREE;
-
- for (i = 0; i < TREE_VEC_LENGTH (basetype_vec); i++)
+ for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (source), i, base_binfo); i++)
{
tree su;
/* We can end up with a NULL_TREE or an incomplete type here if
we encountered previous type resolution errors. It's safe to
simply ignore these cases. */
- if (TREE_VEC_ELT (basetype_vec, i) == NULL_TREE)
- continue;
- su = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+ su = BINFO_TYPE (base_binfo);
if (INCOMPLETE_TYPE_P (su))
continue;
@@ -5259,10 +5262,10 @@ check_inner_circular_reference (tree source, tree target)
static tree
check_circular_reference (tree type)
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (type));
+ tree base_binfo;
int i;
- if (!basetype_vec)
+ if (!BINFO_N_BASE_BINFOS (TYPE_BINFO (type)))
return NULL_TREE;
if (! CLASS_INTERFACE (TYPE_NAME (type)))
@@ -5272,12 +5275,11 @@ check_circular_reference (tree type)
return NULL_TREE;
}
- for (i = 0; i < TREE_VEC_LENGTH (basetype_vec); i++)
+ for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (type), i, base_binfo); i++)
{
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
- if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
- && interface_of_p (type, BINFO_TYPE (vec_elt)))
- return lookup_cl (TYPE_NAME (BINFO_TYPE (vec_elt)));
+ if (BINFO_TYPE (base_binfo) != object_type_node
+ && interface_of_p (type, BINFO_TYPE (base_binfo)))
+ return lookup_cl (TYPE_NAME (BINFO_TYPE (base_binfo)));
}
return NULL_TREE;
}
@@ -5569,8 +5571,9 @@ java_complete_class (void)
/* Simply patch super */
if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
continue;
- BINFO_TYPE (TREE_VEC_ELT (BINFO_BASE_BINFOS (TYPE_BINFO
- (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
+ BINFO_TYPE (BINFO_BASE_BINFO
+ (TYPE_BINFO (TREE_TYPE (JDEP_DECL (dep))), 0))
+ = TREE_TYPE (decl);
break;
case JDEP_FIELD:
@@ -6198,12 +6201,13 @@ check_abstract_method_definitions (int do_interface, tree class_decl,
{
/* Check for implemented interfaces. */
int i;
- tree vector = BINFO_BASE_BINFOS (TYPE_BINFO (type));
- for (i = 1; ok && vector && i < TREE_VEC_LENGTH (vector); i++)
- {
- tree super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
- ok = check_abstract_method_definitions (1, class_decl, super);
- }
+ tree base_binfo;
+
+ for (i = 1;
+ ok && BINFO_BASE_ITERATE (TYPE_BINFO (type), i, base_binfo);
+ i++)
+ ok = check_abstract_method_definitions (1, class_decl,
+ BINFO_TYPE (base_binfo));
}
return ok;
@@ -6216,7 +6220,7 @@ static void
java_check_abstract_method_definitions (tree class_decl)
{
tree class = TREE_TYPE (class_decl);
- tree super, vector;
+ tree super, base_binfo;
int i;
if (CLASS_ABSTRACT (class_decl))
@@ -6230,12 +6234,8 @@ java_check_abstract_method_definitions (tree class_decl)
} while (super != object_type_node);
/* Check for implemented interfaces. */
- vector = BINFO_BASE_BINFOS (TYPE_BINFO (class));
- for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
- {
- super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
- check_abstract_method_definitions (1, class_decl, super);
- }
+ for (i = 1; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
+ check_abstract_method_definitions (1, class_decl, BINFO_TYPE (base_binfo));
}
/* Check all the types method DECL uses and return 1 if all of them
@@ -6493,8 +6493,6 @@ check_interface_throws_clauses (tree check_class_decl, tree class_decl)
{
for (; class_decl != NULL_TREE; class_decl = CLASSTYPE_SUPER (class_decl))
{
- tree bases;
- int iface_len;
int i;
if (! CLASS_LOADED_P (class_decl))
@@ -6505,11 +6503,10 @@ check_interface_throws_clauses (tree check_class_decl, tree class_decl)
load_class (class_decl, 1);
}
- bases = BINFO_BASE_BINFOS (TYPE_BINFO (class_decl));
- iface_len = TREE_VEC_LENGTH (bases) - 1;
- for (i = iface_len; i > 0; --i)
+ for (i = BINFO_N_BASE_BINFOS (TYPE_BINFO (class_decl)) - 1; i > 0; --i)
{
- tree interface = BINFO_TYPE (TREE_VEC_ELT (bases, i));
+ tree interface
+ = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (class_decl), i));
tree iface_method;
for (iface_method = TYPE_METHODS (interface);
@@ -6609,9 +6606,10 @@ check_throws_clauses (tree method, tree method_wfl, tree found)
static void
java_check_abstract_methods (tree interface_decl)
{
- int i, n;
- tree method, basetype_vec, found;
+ int i;
+ tree method, found;
tree interface = TREE_TYPE (interface_decl);
+ tree base_binfo;
for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
{
@@ -6637,16 +6635,11 @@ java_check_abstract_methods (tree interface_decl)
}
/* 4- Inherited methods can't differ by their returned types */
- if (!(basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (interface))))
- return;
- n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 0; i < n; i++)
+ for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (interface), i, base_binfo); i++)
{
tree sub_interface_method, sub_interface;
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
- if (!vec_elt)
- continue;
- sub_interface = BINFO_TYPE (vec_elt);
+
+ sub_interface = BINFO_TYPE (base_binfo);
for (sub_interface_method = TYPE_METHODS (sub_interface);
sub_interface_method;
sub_interface_method = TREE_CHAIN (sub_interface_method))
@@ -6676,26 +6669,21 @@ java_check_abstract_methods (tree interface_decl)
static tree
lookup_java_interface_method2 (tree class, tree method_decl)
{
- int i, n;
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (class));
+ int i;
+ tree base_binfo;
tree to_return;
- if (!basetype_vec)
- return NULL_TREE;
-
- n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 0; i < n; i++)
+ for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
{
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
- if ((BINFO_TYPE (vec_elt) != object_type_node)
+ if ((BINFO_TYPE (base_binfo) != object_type_node)
&& (to_return =
- lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
+ lookup_java_method2 (BINFO_TYPE (base_binfo), method_decl, 1)))
return to_return;
}
- for (i = 0; i < n; i++)
+ for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
{
to_return = lookup_java_interface_method2
- (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
+ (BINFO_TYPE (base_binfo), method_decl);
if (to_return)
return to_return;
}
@@ -10984,6 +10972,8 @@ find_applicable_accessible_methods_list (int lc, tree class, tree name,
static htab_t searched_classes;
static int search_not_done = 0;
tree list = NULL_TREE, all_list = NULL_TREE;
+ tree base_binfo;
+ int i;
/* Check the hash table to determine if this class has been searched
already. */
@@ -11011,16 +11001,13 @@ find_applicable_accessible_methods_list (int lc, tree class, tree name,
if (TREE_CODE (TYPE_NAME (class)) == TYPE_DECL
&& CLASS_INTERFACE (TYPE_NAME (class)))
{
- int i, n;
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (class));
search_applicable_methods_list (lc, TYPE_METHODS (class),
name, arglist, &list, &all_list);
- n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 1; i < n; i++)
+ for (i = 1; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
{
- tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+ tree t = BINFO_TYPE (base_binfo);
tree rlist;
-
+
rlist = find_applicable_accessible_methods_list (lc, t, name,
arglist);
list = chainon (rlist, list);
@@ -11044,21 +11031,20 @@ find_applicable_accessible_methods_list (int lc, tree class, tree name,
/* We must search all interfaces of this class */
if (!lc)
- {
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (class));
- int n = TREE_VEC_LENGTH (basetype_vec), i;
- for (i = 1; i < n; i++)
- {
- tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
- if (t != object_type_node)
- {
- tree rlist
- = find_applicable_accessible_methods_list (lc, t,
- name, arglist);
- list = chainon (rlist, list);
- }
- }
- }
+ {
+ for (i = 1;
+ BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
+ {
+ tree t = BINFO_TYPE (base_binfo);
+ if (t != object_type_node)
+ {
+ tree rlist
+ = find_applicable_accessible_methods_list (lc, t,
+ name, arglist);
+ list = chainon (rlist, list);
+ }
+ }
+ }
/* Search superclass */
if (!lc && CLASSTYPE_SUPER (class) != NULL_TREE)
diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c
index 8a174395530..0e6e404a362 100644
--- a/gcc/java/typeck.c
+++ b/gcc/java/typeck.c
@@ -796,13 +796,12 @@ find_method_in_interfaces (tree searched_class, int flags, tree method_name,
tree signature, tree (*signature_builder) (tree))
{
int i;
- int interface_len =
- TREE_VEC_LENGTH (BINFO_BASE_BINFOS (TYPE_BINFO (searched_class))) - 1;
+ tree binfo, base_binfo;
- for (i = interface_len; i > 0; i--)
+ for (binfo = TYPE_BINFO (searched_class), i = 1;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree child = BINFO_BASE_BINFO (TYPE_BINFO (searched_class), i);
- tree iclass = BINFO_TYPE (child);
+ tree iclass = BINFO_TYPE (base_binfo);
tree method;
/* If the superinterface hasn't been loaded yet, do so now. */
@@ -814,7 +813,7 @@ find_method_in_interfaces (tree searched_class, int flags, tree method_name,
/* First, we look in ICLASS. If that doesn't work we'll
recursively look through all its superinterfaces. */
method = shallow_find_method (iclass, flags, method_name,
- signature, signature_builder);
+ signature, signature_builder);
if (method != NULL_TREE)
return method;
diff --git a/gcc/sdbout.c b/gcc/sdbout.c
index 0398a5ad32b..ef254888f35 100644
--- a/gcc/sdbout.c
+++ b/gcc/sdbout.c
@@ -1109,7 +1109,6 @@ sdbout_one_type (tree type)
int size = int_size_in_bytes (type);
int member_scl = 0;
tree tem;
- int i, n_baseclasses = 0;
/* Record the type tag, but not in its permanent place just yet. */
sdbout_record_type_name (type);
@@ -1149,16 +1148,17 @@ sdbout_one_type (tree type)
/* This is only relevant to aggregate types. TYPE_BINFO is used
for other purposes in an ENUMERAL_TYPE, so we must exclude that
case. */
- if (TREE_CODE (type) != ENUMERAL_TYPE)
+ if (TREE_CODE (type) != ENUMERAL_TYPE && TYPE_BINFO (type))
{
- if (TYPE_BINFO (type) && BINFO_BASE_BINFOS (TYPE_BINFO (type)))
- n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (type));
-
- for (i = 0; i < n_baseclasses; i++)
+ int i;
+ tree binfo, child;
+
+ for (binfo = TYPE_BINFO (type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, child); i++)
{
- tree child = BINFO_BASE_BINFO (TYPE_BINFO (type), i);
tree child_type = BINFO_TYPE (child);
tree child_type_name;
+
if (TYPE_NAME (child_type) == 0)
continue;
if (TREE_CODE (TYPE_NAME (child_type)) == IDENTIFIER_NODE)
diff --git a/gcc/tree-dump.c b/gcc/tree-dump.c
index 659531f0300..d17a8f827be 100644
--- a/gcc/tree-dump.c
+++ b/gcc/tree-dump.c
@@ -251,8 +251,7 @@ dequeue_and_dump (dump_info_p di)
if (dni->binfo_p)
{
unsigned ix;
- tree bases = BINFO_BASE_BINFOS (t);
- unsigned n_bases = bases ? TREE_VEC_LENGTH (bases): 0;
+ tree base;
tree accesses = BINFO_BASE_ACCESSES (t);
dump_child ("type", BINFO_TYPE (t));
@@ -260,10 +259,9 @@ dequeue_and_dump (dump_info_p di)
if (BINFO_VIRTUAL_P (t))
dump_string (di, "virt");
- dump_int (di, "bases", n_bases);
- for (ix = 0; ix != n_bases; ix++)
+ dump_int (di, "bases", BINFO_N_BASE_BINFOS (t));
+ for (ix = 0; BINFO_BASE_ITERATE (t, ix, base); ix++)
{
- tree base = TREE_VEC_ELT (bases, ix);
tree access = (accesses ? TREE_VEC_ELT (accesses, ix)
: access_public_node);
const char *string = NULL;
diff --git a/gcc/tree.c b/gcc/tree.c
index 8066cd100ff..b76b6288a5d 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -94,9 +94,6 @@ struct type_hash GTY(())
tree type;
};
-/* Additional language-dependent binfo slots. */
-unsigned binfo_lang_slots;
-
/* Initial size of the hash table (rounded to next prime). */
#define TYPE_HASH_INITIAL_SIZE 1000
@@ -582,20 +579,11 @@ build_complex (tree type, tree real, tree imag)
/* Build a BINFO with LEN language slots. */
tree
-make_tree_binfo_stat (unsigned lang_slots MEM_STAT_DECL)
+make_tree_binfo_stat (unsigned base_binfos MEM_STAT_DECL)
{
tree t;
- static unsigned length;
-
- if (!length)
- {
- length = (offsetof (struct tree_binfo, lang_slots)
- + (sizeof (((struct tree_binfo *)0)->lang_slots[0])
- * lang_slots));
- binfo_lang_slots = lang_slots;
- }
- else if (binfo_lang_slots != lang_slots)
- abort ();
+ size_t length = (offsetof (struct tree_binfo, base_binfos)
+ + VEC_embedded_size (tree, base_binfos));
#ifdef GATHER_STATISTICS
tree_node_counts[(int) binfo_kind]++;
@@ -604,9 +592,11 @@ make_tree_binfo_stat (unsigned lang_slots MEM_STAT_DECL)
t = ggc_alloc_zone_stat (length, tree_zone PASS_MEM_STAT);
- memset (t, 0, length);
+ memset (t, 0, offsetof (struct tree_binfo, base_binfos));
TREE_SET_CODE (t, TREE_BINFO);
+
+ VEC_embedded_init (tree, BINFO_BASE_BINFOS (t), base_binfos);
return t;
}
diff --git a/gcc/tree.h b/gcc/tree.h
index f37c7a355da..32ede7256a7 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -25,6 +25,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "machmode.h"
#include "input.h"
#include "statistics.h"
+#include "vec.h"
/* Codes of tree nodes */
@@ -74,6 +75,10 @@ extern const unsigned char tree_code_length[];
/* Names of tree components. */
extern const char *const tree_code_name[];
+
+/* A vector of trees. */
+DEF_VEC_P(tree);
+
/* Classify which part of the compiler has defined a given builtin function.
Note that we assume below that this is no more than two bits. */
@@ -1641,20 +1646,19 @@ struct tree_type GTY(())
If this basetype describes type D as inherited in C, and if the
basetypes of D are E and F, then this vector contains binfos for
- inheritance of E and F by C.
-
- ??? This could probably be done by just allocating the
- base types at the end of this TREE_VEC (instead of using
- another TREE_VEC). This would simplify the calculation
- of how many basetypes a given type had. */
-#define BINFO_BASE_BINFOS(NODE) (TREE_BINFO_CHECK(NODE)->binfo.base_binfos)
+ inheritance of E and F by C. */
+#define BINFO_BASE_BINFOS(NODE) (&TREE_BINFO_CHECK(NODE)->binfo.base_binfos)
/* The number of basetypes for NODE. */
-#define BINFO_N_BASE_BINFOS(NODE) \
- (BINFO_BASE_BINFOS (NODE) ? TREE_VEC_LENGTH (BINFO_BASE_BINFOS (NODE)) : 0)
+#define BINFO_N_BASE_BINFOS(NODE) (VEC_length (tree, BINFO_BASE_BINFOS (NODE)))
/* Accessor macro to get to the Nth base binfo of this binfo. */
-#define BINFO_BASE_BINFO(NODE,N) TREE_VEC_ELT (BINFO_BASE_BINFOS (NODE), (N))
+#define BINFO_BASE_BINFO(NODE,N) \
+ (VEC_index (tree, BINFO_BASE_BINFOS (NODE), (N)))
+#define BINFO_BASE_ITERATE(NODE,N,B) \
+ (VEC_iterate (tree, BINFO_BASE_BINFOS (NODE), (N), (B)))
+#define BINFO_BASE_APPEND(NODE,T) \
+ (VEC_quick_push (tree, BINFO_BASE_BINFOS (NODE), (T)))
/* For a BINFO record describing a virtual base class, i.e., one where
TREE_VIA_VIRTUAL is set, this field assists in locating the virtual
@@ -1669,10 +1673,19 @@ struct tree_type GTY(())
#define BINFO_BASE_ACCESSES(NODE) (TREE_BINFO_CHECK(NODE)->binfo.base_accesses)
#define BINFO_BASE_ACCESS(NODE,N) TREE_VEC_ELT (BINFO_BASE_ACCESSES(NODE), (N))
-/* Number of language independent elements in a binfo. Languages may
- add additional trailing elements. */
+/* 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) (TREE_BINFO_CHECK(NODE)->binfo.vtt_subvtt)
-#define BINFO_LANG_SLOT(NODE,N) (TREE_BINFO_CHECK(NODE)->binfo.lang_slots[N])
+/* 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) (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
inheriting this base for non-virtual bases. For virtual bases it
@@ -1687,14 +1700,16 @@ struct tree_binfo GTY (())
tree offset;
tree vtable;
tree virtuals;
- tree base_binfos;
tree vptr_field;
tree base_accesses;
tree inheritance;
- tree GTY ((length ("binfo_lang_slots"))) lang_slots[1];
+ tree vtt_subvtt;
+ tree vtt_vptr;
+ tree primary;
+
+ VEC(tree) base_binfos;
};
-extern GTY (()) unsigned binfo_lang_slots;
/* Define fields and accessors for nodes representing declared names. */