* cp-tree.h (TYPE_VIRTUAL_P): Rename to ...
(TYPE_POLYMORPHIC_P): ... this.
(TYPE_USES_COMPLEX_INHERITANCE): Rename to ...
(TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P): ... this.
(TREE_CALLS_NEW): Remove.
(TREE_MANGLED): Likewise.
* call.c (build_vfield_ref): Use TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P,
and TYPE_POLYMORPHIC_P.
* class.c (check_bases): Likewise.
(finish_base_struct): Likewise.
(finish_struct_bits): Likewise.
(check_for_override): Likewise.
(finish_struct_1): Likewise.
(get_vfield_name): Likewise.
* decl.c (xref_basetypes): Likewise.
* decl2.c (import_export_class): Likewise.
(import_export_decl): Likewise.
* error.c (dump_function_decl): Likewise.
* pt.c (instantiate_class_template): Likewise.
* repo.c (repo_inline_used): Likewise.
* rtti.c (build_headof): Likewise.
(get_tinfo_fn_dynamic): Likewise.
(build_x_typeid): Likewise.
(get_tinfo_var): Likewise.
(build_dynamic_cast_1): Likewise.
(synthesize_tinfo_fn): Likewise.
* search.c (lookup_field_1): Likewise.
(dfs_debug_mark): Likewise.
(maybe_suppress_debug_info): Likewise.
* typeck.c (build_component_ref): Likewise.
(build_component_addr): Likewise.
* typeck2.c (process_init_constructor): Likewise.
From-SVN: r31041
+1999-12-20 Mark Mitchell <mark@codesourcery.com>
+
+ * cp-tree.h (TYPE_VIRTUAL_P): Rename to ...
+ (TYPE_POLYMORPHIC_P): ... this.
+ (TYPE_USES_COMPLEX_INHERITANCE): Rename to ...
+ (TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P): ... this.
+ (TREE_CALLS_NEW): Remove.
+ (TREE_MANGLED): Likewise.
+ * call.c (build_vfield_ref): Use TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P,
+ and TYPE_POLYMORPHIC_P.
+ * class.c (check_bases): Likewise.
+ (finish_base_struct): Likewise.
+ (finish_struct_bits): Likewise.
+ (check_for_override): Likewise.
+ (finish_struct_1): Likewise.
+ (get_vfield_name): Likewise.
+ * decl.c (xref_basetypes): Likewise.
+ * decl2.c (import_export_class): Likewise.
+ (import_export_decl): Likewise.
+ * error.c (dump_function_decl): Likewise.
+ * pt.c (instantiate_class_template): Likewise.
+ * repo.c (repo_inline_used): Likewise.
+ * rtti.c (build_headof): Likewise.
+ (get_tinfo_fn_dynamic): Likewise.
+ (build_x_typeid): Likewise.
+ (get_tinfo_var): Likewise.
+ (build_dynamic_cast_1): Likewise.
+ (synthesize_tinfo_fn): Likewise.
+ * search.c (lookup_field_1): Likewise.
+ (dfs_debug_mark): Likewise.
+ (maybe_suppress_debug_info): Likewise.
+ * typeck.c (build_component_ref): Likewise.
+ (build_component_addr): Likewise.
+ * typeck2.c (process_init_constructor): Likewise.
+
1999-12-20 Nathan Sidwell <nathan@acm.org>
* typeck.c (strip_all_pointer_quals): New static function.
if (TREE_CODE (TREE_TYPE (datum)) == REFERENCE_TYPE)
datum = convert_from_reference (datum);
- if (! TYPE_USES_COMPLEX_INHERITANCE (type))
+ if (! TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (type))
rval = build (COMPONENT_REF, TREE_TYPE (TYPE_VFIELD (type)),
datum, TYPE_VFIELD (type));
else
continue;
}
- /* Effective C++ rule 14. We only need to check TYPE_VIRTUAL_P
+ /* Effective C++ rule 14. We only need to check TYPE_POLYMORPHIC_P
here because the case of virtual functions but non-virtual
dtor is handled in finish_struct_1. */
- if (warn_ecpp && ! TYPE_VIRTUAL_P (basetype)
+ if (warn_ecpp && ! TYPE_POLYMORPHIC_P (basetype)
&& TYPE_HAS_DESTRUCTOR (basetype))
cp_warning ("base class `%#T' has a non-virtual destructor",
basetype);
TYPE_OVERLOADS_CALL_EXPR (t) |= TYPE_OVERLOADS_CALL_EXPR (basetype);
TYPE_OVERLOADS_ARRAY_REF (t) |= TYPE_OVERLOADS_ARRAY_REF (basetype);
TYPE_OVERLOADS_ARROW (t) |= TYPE_OVERLOADS_ARROW (basetype);
+ TYPE_POLYMORPHIC_P (t) |= TYPE_POLYMORPHIC_P (basetype);
/* Derived classes can implicitly become COMified if their bases
are COM. */
tree base_binfo = TREE_VEC_ELT (binfos, i);
tree basetype = BINFO_TYPE (base_binfo);
- if (TYPE_VIRTUAL_P (basetype))
+ if (TYPE_POLYMORPHIC_P (basetype))
{
/* Ensure that this is set from at least a virtual base
class. */
TYPE_NEEDS_CONSTRUCTING (variants) = TYPE_NEEDS_CONSTRUCTING (t);
TYPE_NEEDS_DESTRUCTOR (variants) = TYPE_NEEDS_DESTRUCTOR (t);
- TYPE_USES_COMPLEX_INHERITANCE (variants) = TYPE_USES_COMPLEX_INHERITANCE (t);
- TYPE_VIRTUAL_P (variants) = TYPE_VIRTUAL_P (t);
+ TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (variants)
+ = TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (t);
+ TYPE_POLYMORPHIC_P (variants) = TYPE_POLYMORPHIC_P (t);
TYPE_USES_VIRTUAL_BASECLASSES (variants) = TYPE_USES_VIRTUAL_BASECLASSES (t);
/* Copy whatever these are holding today. */
TYPE_MIN_VALUE (variants) = TYPE_MIN_VALUE (t);
for (i = 0; i < n_baselinks; i++)
{
tree base_binfo = TREE_VEC_ELT (binfos, i);
- if (TYPE_VIRTUAL_P (BINFO_TYPE (base_binfo)))
+ if (TYPE_POLYMORPHIC_P (BINFO_TYPE (base_binfo)))
{
tree tmp = get_matching_virtual
(base_binfo, decl,
= size_binop (PLUS_EXPR, offset, DECL_FIELD_BITPOS (vfield));
TYPE_VFIELD (t) = vfield;
}
+
+ /* If this vtbl pointer is new, add it to the list of vtbl
+ pointers in this class. */
if (has_virtual > max_has_virtual)
max_has_virtual = has_virtual;
if (max_has_virtual > 0)
- TYPE_VIRTUAL_P (t) = 1;
+ TYPE_POLYMORPHIC_P (t) = 1;
- if (flag_rtti && TYPE_VIRTUAL_P (t) && !pending_hard_virtuals)
+ if (flag_rtti && TYPE_POLYMORPHIC_P (t) && !pending_hard_virtuals)
modify_all_vtables (t, NULL_TREE);
- while (pending_hard_virtuals)
- {
- modify_all_vtables (t,
- TREE_VALUE (pending_hard_virtuals));
- pending_hard_virtuals = TREE_CHAIN (pending_hard_virtuals);
- }
+ for (pending_hard_virtuals = nreverse (pending_hard_virtuals);
+ pending_hard_virtuals;
+ pending_hard_virtuals = TREE_CHAIN (pending_hard_virtuals))
+ modify_all_vtables (t, TREE_VALUE (pending_hard_virtuals));
if (TYPE_USES_VIRTUAL_BASECLASSES (t))
{
char *buf;
while (BINFO_BASETYPES (binfo)
- && TYPE_VIRTUAL_P (BINFO_TYPE (BINFO_BASETYPE (binfo, 0)))
+ && TYPE_POLYMORPHIC_P (BINFO_TYPE (BINFO_BASETYPE (binfo, 0)))
&& ! TREE_VIA_VIRTUAL (BINFO_BASETYPE (binfo, 0)))
binfo = BINFO_BASETYPE (binfo, 0);
TEMPLATE_PARMS_FOR_INLINE.
DELETE_EXPR_USE_VEC (in DELETE_EXPR).
(TREE_CALLS_NEW) (in _EXPR or _REF) (commented-out).
- TYPE_USES_COMPLEX_INHERITANCE (in _TYPE).
+ TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (in _TYPE).
C_DECLARED_LABEL_FLAG (in LABEL_DECL)
INHERITED_VALUE_BINDING_P (in CPLUS_BINDING)
BASELINK_P (in TREE_LIST)
2: IDENTIFIER_OPNAME_P.
BINFO_VBASE_MARKED.
BINFO_FIELDS_MARKED.
- TYPE_VIRTUAL_P.
+ TYPE_POLYMORHPIC_P (in _TYPE)
ICS_THIS_FLAG (in _CONV)
STMT_LINENO_FOR_FN_P (in _STMT)
BINDING_HAS_LEVEL_P (in CPLUS_BINDING)
using a twos-complement negated operand. */
#define TREE_NEGATED_INT(NODE) TREE_LANG_FLAG_0 (INTEGER_CST_CHECK (NODE))
-#if 0 /* UNUSED */
-/* Nonzero in any kind of _EXPR or _REF node means that it is a call
- to a storage allocation routine. If, later, alternate storage
- is found to hold the object, this call can be ignored. */
-#define TREE_CALLS_NEW(NODE) (TREE_LANG_FLAG_1 (NODE))
-#endif
-
-/* Nonzero in any kind of _TYPE that uses multiple inheritance
- or virtual baseclasses. */
-#define TYPE_USES_COMPLEX_INHERITANCE(NODE) (TREE_LANG_FLAG_1 (NODE))
-
-#if 0 /* UNUSED */
-/* Nonzero in IDENTIFIER_NODE means that this name is not the name the user
- gave; it's a DECL_NESTED_TYPENAME. Someone may want to set this on
- mangled function names, too, but it isn't currently. */
-#define TREE_MANGLED(NODE) (FOO)
-#endif
-
-#if 0 /* UNUSED */
-/* Nonzero in IDENTIFIER_NODE means that this name is overloaded, and
- should be looked up in a non-standard way. */
-#define DECL_OVERLOADED(NODE) (FOO)
-#endif
+/* Nonzero in any kind of _TYPE where conversions to base-classes may
+ involve pointer arithmetic. If this is zero, then converting to
+ a base-class never requires changing the value of the pointer. */
+#define TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P(NODE) (TREE_LANG_FLAG_1 (NODE))
-/* Nonzero if this (non-TYPE)_DECL has its virtual attribute set.
- For a FUNCTION_DECL, this is when the function is a virtual function.
- For a VAR_DECL, this is when the variable is a virtual function table.
- For a FIELD_DECL, when the field is the field for the virtual function table.
- For an IDENTIFIER_NODE, nonzero if any function with this name
- has been declared virtual.
+/* [class.virtual]
- For a _TYPE if it uses virtual functions (or is derived from
- one that does). */
-#define TYPE_VIRTUAL_P(NODE) (TREE_LANG_FLAG_2 (NODE))
+ A class that declares or inherits a virtual function is called a
+ polymorphic class. */
+#define TYPE_POLYMORPHIC_P(NODE) (TREE_LANG_FLAG_2 (NODE))
extern int flag_new_for_scope;
if (via_virtual || TYPE_USES_VIRTUAL_BASECLASSES (basetype))
{
TYPE_USES_VIRTUAL_BASECLASSES (ref) = 1;
- TYPE_USES_COMPLEX_INHERITANCE (ref) = 1;
+ /* Converting to a virtual base class requires looking
+ up the offset of the virtual base. */
+ TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref) = 1;
}
if (CLASS_TYPE_P (basetype))
{
TYPE_GETS_NEW (ref) |= TYPE_GETS_NEW (basetype);
TYPE_GETS_DELETE (ref) |= TYPE_GETS_DELETE (basetype);
+ /* If the base-class uses multiple inheritance, so do we. */
+ TYPE_USES_MULTIPLE_INHERITANCE (ref)
+ |= TYPE_USES_MULTIPLE_INHERITANCE (basetype);
+ /* Likewise, if converting to a base of the base may require
+ code, then we may need to generate code to convert to a
+ base as well. */
+ TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref)
+ |= TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (basetype);
}
i += 1;
BINFO_BASETYPES (TYPE_BINFO (ref)) = NULL_TREE;
if (i > 1)
- TYPE_USES_MULTIPLE_INHERITANCE (ref) = 1;
- else if (i == 1)
{
- tree basetype = BINFO_TYPE (TREE_VEC_ELT (binfos, 0));
-
- if (CLASS_TYPE_P (basetype))
- TYPE_USES_MULTIPLE_INHERITANCE (ref)
- = TYPE_USES_MULTIPLE_INHERITANCE (basetype);
+ TYPE_USES_MULTIPLE_INHERITANCE (ref) = 1;
+ /* If there is more than one non-empty they cannot be at the same
+ address. */
+ TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref) = 1;
}
- if (TYPE_USES_MULTIPLE_INHERITANCE (ref))
- TYPE_USES_COMPLEX_INHERITANCE (ref) = 1;
-
/* Unmark all the types. */
while (--i >= 0)
CLEAR_CLASSTYPE_MARKED (BINFO_TYPE (TREE_VEC_ELT (binfos, i)));
/* Base our import/export status on that of the first non-inline,
non-abstract virtual function, if any. */
if (import_export == 0
- && TYPE_VIRTUAL_P (ctype)
+ && TYPE_POLYMORPHIC_P (ctype)
&& ! CLASSTYPE_TEMPLATE_INSTANTIATION (ctype))
{
tree method;
import_export_class (ctype);
if (IS_AGGR_TYPE (ctype) && CLASSTYPE_INTERFACE_KNOWN (ctype)
- && TYPE_VIRTUAL_P (ctype)
+ && TYPE_POLYMORPHIC_P (ctype)
/* If -fno-rtti, we're not necessarily emitting this stuff with
the class, so go ahead and emit it now. This can happen
when a class is used in exception handling. */
/* OK */;
else if (DECL_STATIC_FUNCTION_P (t))
OB_PUTS ("static ");
- else if (TYPE_VIRTUAL_P (t))
+ else if (TYPE_POLYMORPHIC_P (t))
OB_PUTS ("virtual ");
/* Print the return type? */
TYPE_HAS_CONST_INIT_REF (type) = TYPE_HAS_CONST_INIT_REF (pattern);
TYPE_HAS_DEFAULT_CONSTRUCTOR (type) = TYPE_HAS_DEFAULT_CONSTRUCTOR (pattern);
TYPE_HAS_CONVERSION (type) = TYPE_HAS_CONVERSION (pattern);
- TYPE_USES_COMPLEX_INHERITANCE (type)
- = TYPE_USES_COMPLEX_INHERITANCE (pattern);
+ TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (type)
+ = TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (pattern);
TYPE_USES_MULTIPLE_INHERITANCE (type)
= TYPE_USES_MULTIPLE_INHERITANCE (pattern);
TYPE_USES_VIRTUAL_BASECLASSES (type)
return;
/* Member functions of polymorphic classes go with their vtables. */
- if (DECL_FUNCTION_MEMBER_P (fn) && TYPE_VIRTUAL_P (DECL_CLASS_CONTEXT (fn)))
+ if (DECL_FUNCTION_MEMBER_P (fn)
+ && TYPE_POLYMORPHIC_P (DECL_CLASS_CONTEXT (fn)))
{
repo_vtable_used (DECL_CLASS_CONTEXT (fn));
return;
/* Given the expression EXP of type `class *', return the head of the
object pointed to by EXP with type cv void*, if the class has any
- virtual functions (TYPE_VIRTUAL_P), else just return the
+ virtual functions (TYPE_POLYMORPHIC_P), else just return the
expression. */
static tree
}
type = TREE_TYPE (type);
- if (!TYPE_VIRTUAL_P (type))
+ if (!TYPE_POLYMORPHIC_P (type))
return exp;
if (CLASSTYPE_COM_INTERFACE (type))
{
}
/* If exp is a reference to polymorphic type, get the real type_info. */
- if (TYPE_VIRTUAL_P (type) && ! resolves_to_fixed_type_p (exp, 0))
+ if (TYPE_POLYMORPHIC_P (type) && ! resolves_to_fixed_type_p (exp, 0))
{
/* build reference to type_info from vtable. */
tree t;
if (TREE_CODE (exp) == INDIRECT_REF
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == POINTER_TYPE
- && TYPE_VIRTUAL_P (TREE_TYPE (exp))
+ && TYPE_POLYMORPHIC_P (TREE_TYPE (exp))
&& ! resolves_to_fixed_type_p (exp, &nonnull)
&& ! nonnull)
{
{
if (CLASSTYPE_N_BASECLASSES (type) == 0)
size = 2 * POINTER_SIZE;
- else if (! TYPE_USES_COMPLEX_INHERITANCE (type)
+ else if (! TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (type)
&& (TREE_VIA_PUBLIC
(TREE_VEC_ELT (TYPE_BINFO_BASETYPES (type), 0))))
size = 3 * POINTER_SIZE;
}
/* Otherwise *exprtype must be a polymorphic class (have a vtbl). */
- if (TYPE_VIRTUAL_P (TREE_TYPE (exprtype)))
+ if (TYPE_POLYMORPHIC_P (TREE_TYPE (exprtype)))
{
tree expr1;
/* if TYPE is `void *', return pointer to complete object. */
{
if (CLASSTYPE_N_BASECLASSES (type) == 0)
expand_generic_desc (tdecl, type, "__rtti_user");
- else if (! TYPE_USES_COMPLEX_INHERITANCE (type)
+ else if (! TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (type)
&& (TREE_VIA_PUBLIC
(TREE_VEC_ELT (TYPE_BINFO_BASETYPES (type), 0))))
expand_si_desc (tdecl, type);
if (name == vptr_identifier)
{
/* Give the user what s/he thinks s/he wants. */
- if (TYPE_VIRTUAL_P (type))
+ if (TYPE_POLYMORPHIC_P (type))
return TYPE_VFIELD (type);
}
return NULL_TREE;
/* If the class has virtual functions, we'll emit the debug info
with the vtable. */
- if (TYPE_VIRTUAL_P (t))
+ if (TYPE_POLYMORPHIC_P (t))
return NULL_TREE;
/* We cannot rely on some alien method to solve our problems,
/* Don't set it. */;
/* If the class has virtual functions, write out the debug info
along with the vtable. */
- else if (TYPE_VIRTUAL_P (t))
+ else if (TYPE_POLYMORPHIC_P (t))
TYPE_DECL_SUPPRESS_DEBUG (TYPE_MAIN_DECL (t)) = 1;
/* Otherwise, just emit the debug info normally. */
}
/* Handle base classes here... */
- if (base != basetype && TYPE_USES_COMPLEX_INHERITANCE (basetype))
+ if (base != basetype && TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (basetype))
{
tree addr = build_unary_op (ADDR_EXPR, datum, 0);
if (integer_zerop (addr))
}
if (TREE_CODE (field) == FIELD_DECL
- && TYPE_USES_COMPLEX_INHERITANCE (basetype))
+ && TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (basetype))
{
/* Can't convert directly to ARGTYPE, since that
may have the same pointer type as one of our
return error_mark_node;
}
- if (TYPE_VIRTUAL_P (type))
+ if (TYPE_POLYMORPHIC_P (type))
{
sorry ("initializer list for object using virtual functions");
return error_mark_node;