+2004-10-11 Nathan Sidwell <nathan@codesourcery.com>
+
+ * cp-tree.h (SAME_BINFO_TYPE_P): New.
+ * class.c (build_base_path): Use SAME_BINFO_TYPE_P to compare
+ binfo types.
+ (convert_to_base_statically, determine_primary_bases,
+ update_vtable_entry_for_fn, dfs_modify_vtables, build_vtt_inits,
+ dfs_build_secondary_vptr_vtt_inits, build_ctor_vtbl_group,
+ accumulate_vtbl_inits, dfs_accumulate_vtbl_inits,
+ build_vtbl_initializer, add_vcall_offset_vtbl_entries_1): Likewise.
+ * init.c (expand_member_init): Likewise.
+ * search.c (lookup_base_r, dynamic_cast_base_recurse,
+ binfo_via_virtual, copied_binfo, binfo_for_vbase,
+ original_binfo): Likewise.
+ * tree.c (copy_binfo): Likewise.
+
2004-10-11 Kazu Hirata <kazu@cs.umass.edu>
* semantics.c: Fix comment typos.
if (want_pointer)
probe = TYPE_MAIN_VARIANT (TREE_TYPE (probe));
- gcc_assert (code == MINUS_EXPR
- ? same_type_p (BINFO_TYPE (binfo), probe)
- : code == PLUS_EXPR
- ? same_type_p (BINFO_TYPE (d_binfo), probe)
- : false);
+ gcc_assert ((code == MINUS_EXPR
+ && SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), probe))
+ || (code == PLUS_EXPR
+ && SAME_BINFO_TYPE_P (BINFO_TYPE (d_binfo), probe)));
if (binfo == d_binfo)
/* Nothing to do. */
return build_base_path (PLUS_EXPR, object, binfo, /*nonnull=*/1);
}
-/* EXPR is an expression with class type. BASE is a base class (a
- BINFO) of that class type. Returns EXPR, converted to the BASE
+/* EXPR is an expression with unqualified class type. BASE is a base
+ binfo of that class type. Returns EXPR, converted to the BASE
type. This function assumes that EXPR is the most derived class;
therefore virtual bases can be found at their static offsets. */
tree expr_type;
expr_type = TREE_TYPE (expr);
- if (!same_type_p (expr_type, BINFO_TYPE (base)))
+ if (!SAME_BINFO_TYPE_P (BINFO_TYPE (base), expr_type))
{
tree pointer_type;
tree parent_primary = CLASSTYPE_PRIMARY_BINFO (BINFO_TYPE (parent));
if (parent_primary
- && BINFO_TYPE (base_binfo) == BINFO_TYPE (parent_primary))
+ && SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo),
+ BINFO_TYPE (parent_primary)))
/* We are the primary binfo. */
BINFO_PRIMARY_P (base_binfo) = 1;
}
{
/* If we find the final overrider, then we can stop
walking. */
- if (same_type_p (BINFO_TYPE (b),
- BINFO_TYPE (TREE_VALUE (overrider))))
+ if (SAME_BINFO_TYPE_P (BINFO_TYPE (b),
+ BINFO_TYPE (TREE_VALUE (overrider))))
break;
/* If we find a virtual base, and we haven't yet found the
/* Similarly, a base without a vtable needs no modification. */
&& TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo))
/* Don't do the primary vtable, if it's new. */
- && (BINFO_TYPE (binfo) != t || CLASSTYPE_HAS_PRIMARY_BASE_P (t)))
+ && (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t)
+ || CLASSTYPE_HAS_PRIMARY_BASE_P (t)))
{
tree virtuals;
tree old_virtuals;
tree init;
tree secondary_vptrs;
secondary_vptr_vtt_init_data data;
- int top_level_p = same_type_p (TREE_TYPE (binfo), t);
+ int top_level_p = SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t);
/* We only need VTTs for subobjects with virtual bases. */
if (!CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)))
/* We're only interested in proper subobjects of the type being
constructed. */
- if (same_type_p (BINFO_TYPE (binfo), data->type_being_constructed))
+ if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), data->type_being_constructed))
return NULL_TREE;
/* We're only interested in bases with virtual bases or reachable
if (IDENTIFIER_GLOBAL_VALUE (id))
return;
- gcc_assert (!same_type_p (BINFO_TYPE (binfo), t));
+ gcc_assert (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t));
/* Build a version of VTBL (with the wrong type) for use in
constructing the addresses of secondary vtables in the
construction vtable group. */
{
int i;
tree base_binfo;
- int ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t);
+ int ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t);
- gcc_assert (same_type_p (BINFO_TYPE (binfo), BINFO_TYPE (orig_binfo)));
+ gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), BINFO_TYPE (orig_binfo)));
/* If it doesn't have a vptr, we don't do anything. */
if (!TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo)))
{
tree inits = NULL_TREE;
tree vtbl = NULL_TREE;
- int ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t);
+ int ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t);
if (ctor_vtbl_p
&& BINFO_VIRTUAL_P (orig_binfo) && BINFO_PRIMARY_P (orig_binfo))
vid.derived = t;
vid.rtti_binfo = rtti_binfo;
vid.last_init = &vid.inits;
- vid.primary_vtbl_p = (binfo == TYPE_BINFO (t));
- vid.ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t);
+ vid.primary_vtbl_p = SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t);
+ vid.ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t);
vid.generate_vcall_entries = true;
/* The first vbase or vcall offset is at index -3 in the vtable. */
vid.index = ssize_int(-3 * TARGET_VTABLE_DATA_ENTRY_DISTANCE);
/* When processing BINFO, we only want to generate vcall slots for
function slots introduced in BINFO. So don't try to generate
one if the function isn't even defined in BINFO. */
- if (!same_type_p (DECL_CONTEXT (orig_fn), BINFO_TYPE (binfo)))
+ if (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), DECL_CONTEXT (orig_fn)))
continue;
add_vcall_offset (orig_fn, binfo, vid);
tree base_binfo;
base_kind found = bk_not_base;
- if (same_type_p (BINFO_TYPE (binfo), base))
+ if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), base))
{
/* We have found a base. Check against what we have found
already. */
int i;
int worst = -2;
- if (BINFO_TYPE (binfo) == subtype)
+ if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), subtype))
{
if (is_via_virtual)
return -1;
tree
binfo_via_virtual (tree binfo, tree limit)
{
- for (; binfo && (!limit || !same_type_p (BINFO_TYPE (binfo), limit));
+ for (; binfo && !SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), limit);
binfo = BINFO_INHERITANCE_CHAIN (binfo))
{
if (BINFO_VIRTUAL_P (binfo))
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))
+ if (SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo), BINFO_TYPE (binfo)))
{
result = base_binfo;
break;
}
else
{
- gcc_assert (BINFO_TYPE (here) == BINFO_TYPE (binfo));
+ gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (here), BINFO_TYPE (binfo)));
result = here;
}
for (vbases = CLASSTYPE_VBASECLASSES (t), ix = 0;
VEC_iterate (tree, vbases, ix, binfo); ix++)
- if (BINFO_TYPE (binfo) == base)
+ if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), base))
return binfo;
return NULL;
}
{
tree result = NULL;
- if (BINFO_TYPE (binfo) == BINFO_TYPE (here))
+ if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), BINFO_TYPE (here)))
result = here;
else if (BINFO_VIRTUAL_P (binfo))
result = (CLASSTYPE_VBASECLASSES (BINFO_TYPE (here))
tree base_binfo;
for (ix = 0; (base_binfo = BINFO_BASE_BINFO (base_binfos, ix)); ix++)
- if (BINFO_TYPE (base_binfo) == BINFO_TYPE (binfo))
+ if (SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo),
+ BINFO_TYPE (binfo)))
{
result = base_binfo;
break;