+2004-09-21 Nathan Sidwell <nathan@codesourcery.com>
+
+ * cp-tree.h (struct lang_type_header): Remove
+ uses_multiple_inheritance field.
+ (TYPE_USES_MULTIPLE_INHERITANCE): Remove.
+ (TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P): Remove.
+ (TYPE_USES_VIRTUAL_BASECLASSES): Remove.
+ (DECL_NEEDS_VTT_PARM_P): Use CLASSTYPE_VBASECLASSES.
+ (TYPE_CONTAINS_VPTR_P): Likewise.
+ * call.c (add_template_candidate_real): Use
+ CLASSTYPE_VBASECLASSES.
+ (build_special_member_call): Likewise.
+ * class.c (finish_struct_bits): Remove
+ TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P & TYPE_USES_VIRTUAL_BASECLASSES
+ bookkeeping.
+ (check_bases_and_members): Use TYPE_CONTAINS_VPTR_P.
+ (create_vtable_ptr): Remove TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P
+ bookkeeping.
+ (build_vtt_inits): Use CLASSTYPE_VBASECLASSES.
+ (accumulate_vtbl_inits, build_vbase_offset_vtbl_entries):
+ Likewise.
+ * decl.c (xref_basetypes): Remove TYPE_USES_MULTIPLE_INHERITANCE,
+ TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P, TYPE_USES_VIRTUAL_BASECLASSES
+ bookkeeping.
+ (cxx_maybe_build_cleanup): Use CLASSTYPE_VBASECLASSES.
+ * decl2.c (maybe_retrofit_in_chrg): Likewise.
+ * init.c (expand_member, push_base_cleanups): Likewise.
+ * pt.c (instantiate_class_template): Remove
+ TYPE_USES_MULTIPLE_INHERITANCE,
+ TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P, TYPE_USES_VIRTUAL_BASECLASSES
+ bookkeeping.
+ * ptree.c (cxx_print_type): Remove TYPE_USES_MULTIPLE_INHERITANCE
+ check.
+ * typeck2.c (process_init_constructor): Replace some sorrys with
+ asserts.
+
2004-09-21 Andreas Tobler <a.tobler@schweiz.ch>
* decl.c (reshape_init_array): Initialize max_index_cst to fix
if ((DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (tmpl)
|| DECL_BASE_CONSTRUCTOR_P (tmpl))
- && TYPE_USES_VIRTUAL_BASECLASSES (DECL_CONTEXT (tmpl)))
+ && CLASSTYPE_VBASECLASSES (DECL_CONTEXT (tmpl)))
args_without_in_chrg = TREE_CHAIN (args_without_in_chrg);
i = fn_type_unification (tmpl, explicit_targs, targs,
the subobject. */
if ((name == base_ctor_identifier
|| name == base_dtor_identifier)
- && TYPE_USES_VIRTUAL_BASECLASSES (class_type))
+ && CLASSTYPE_VBASECLASSES (class_type))
{
tree vtt;
tree sub_vtt;
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (variants)
= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (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);
TYPE_BINFO (variants) = TYPE_BINFO (t);
/* Do some bookkeeping that will guide the generation of implicitly
declared member functions. */
TYPE_HAS_COMPLEX_INIT_REF (t)
- |= (TYPE_HAS_INIT_REF (t)
- || TYPE_USES_VIRTUAL_BASECLASSES (t)
- || TYPE_POLYMORPHIC_P (t));
+ |= (TYPE_HAS_INIT_REF (t) || TYPE_CONTAINS_VPTR_P (t));
TYPE_NEEDS_CONSTRUCTING (t)
- |= (TYPE_HAS_CONSTRUCTOR (t)
- || TYPE_USES_VIRTUAL_BASECLASSES (t)
- || TYPE_POLYMORPHIC_P (t));
- CLASSTYPE_NON_AGGREGATE (t) |= (TYPE_HAS_CONSTRUCTOR (t)
- || TYPE_POLYMORPHIC_P (t));
+ |= (TYPE_HAS_CONSTRUCTOR (t) || TYPE_CONTAINS_VPTR_P (t));
+ CLASSTYPE_NON_AGGREGATE (t)
+ |= (TYPE_HAS_CONSTRUCTOR (t) || TYPE_POLYMORPHIC_P (t));
CLASSTYPE_NON_POD_P (t)
|= (CLASSTYPE_NON_AGGREGATE (t) || TYPE_HAS_DESTRUCTOR (t)
|| TYPE_HAS_ASSIGN_REF (t));
/* This class is non-empty. */
CLASSTYPE_EMPTY_P (t) = 0;
- if (BINFO_N_BASE_BINFOS (TYPE_BINFO (t)))
- /* If there were any baseclasses, they can't possibly be at
- offset zero any more, because that's where the vtable
- pointer is. So, converting to a base class is going to
- take work. */
- TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (t) = 1;
-
return field;
}
int top_level_p = same_type_p (TREE_TYPE (binfo), t);
/* We only need VTTs for subobjects with virtual bases. */
- if (!TYPE_USES_VIRTUAL_BASECLASSES (BINFO_TYPE (binfo)))
+ if (!CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)))
return inits;
/* We need to use a construction vtable if this is not the primary
/* If BINFO has virtual bases or is reachable via a virtual path
from T, it'll have a secondary vptr. */
- if (!TYPE_USES_VIRTUAL_BASECLASSES (BINFO_TYPE (binfo))
+ if (!CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo))
&& !binfo_via_virtual (binfo, t))
return NULL_TREE;
/* If we're building a construction vtable, we're not interested in
subobjects that don't require construction vtables. */
if (ctor_vtbl_p
- && !TYPE_USES_VIRTUAL_BASECLASSES (BINFO_TYPE (binfo))
+ && !CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo))
&& !binfo_via_virtual (orig_binfo, BINFO_TYPE (rtti_binfo)))
return;
/* If there are no virtual baseclasses, then there is nothing to
do. */
- if (!TYPE_USES_VIRTUAL_BASECLASSES (BINFO_TYPE (binfo)))
+ if (!CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)))
return;
t = vid->derived;
TEMPLATE_PARMS_FOR_INLINE.
DELETE_EXPR_USE_VEC (in DELETE_EXPR).
(TREE_CALLS_NEW) (in _EXPR or _REF) (commented-out).
- TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (in _TYPE).
ICS_ELLIPSIS_FLAG (in _CONV)
DECL_INITIALIZED_P (in VAR_DECL)
2: IDENTIFIER_OPNAME_P (in IDENTIFIER_NODE)
ICS_THIS_FLAG (in _CONV)
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (in VAR_DECL)
STATEMENT_LIST_TRY_BLOCK (in STATEMENT_LIST)
- 3: TYPE_USES_VIRTUAL_BASECLASSES (in a class TYPE).
- (TREE_REFERENCE_EXPR) (in NON_LVALUE_EXPR) (commented-out).
+ 3: (TREE_REFERENCE_EXPR) (in NON_LVALUE_EXPR) (commented-out).
ICS_BAD_FLAG (in _CONV)
FN_TRY_BLOCK_P (in TRY_BLOCK)
IDENTIFIER_CTOR_OR_DTOR_P (in IDENTIFIER_NODE)
BOOL_BITFIELD has_type_conversion : 1;
BOOL_BITFIELD has_init_ref : 1;
BOOL_BITFIELD has_default_ctor : 1;
- BOOL_BITFIELD uses_multiple_inheritance : 1;
BOOL_BITFIELD const_needs_init : 1;
BOOL_BITFIELD ref_needs_init : 1;
BOOL_BITFIELD has_const_assign_ref : 1;
+
+ BOOL_BITFIELD spare : 1;
};
/* This structure provides additional information above and beyond
convenient, don't reprocess any methods that appear in its redefinition. */
#define TYPE_REDEFINED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->redefined)
-/* Nonzero means that this _CLASSTYPE (or one of its ancestors) uses
- multiple inheritance. If this is 0 for the root of a type
- hierarchy, then we can use more efficient search techniques. */
-#define TYPE_USES_MULTIPLE_INHERITANCE(NODE) \
- (LANG_TYPE_CLASS_CHECK (NODE)->h.uses_multiple_inheritance)
-
-/* Nonzero means that this _CLASSTYPE (or one of its ancestors) uses
- virtual base classes. If this is 0 for the root of a type
- hierarchy, then we can use more efficient search techniques. */
-#define TYPE_USES_VIRTUAL_BASECLASSES(NODE) (TREE_LANG_FLAG_3 (NODE))
-
/* The member function with which the vtable will be emitted:
the first noninline non-pure-virtual member function. NULL_TREE
if there is no key function or if this is a class template */
/* Nonzero if NODE is a FUNCTION_DECL for which a VTT parameter is
required. */
#define DECL_NEEDS_VTT_PARM_P(NODE) \
- (TYPE_USES_VIRTUAL_BASECLASSES (DECL_CONTEXT (NODE)) \
+ (CLASSTYPE_VBASECLASSES (DECL_CONTEXT (NODE)) \
&& (DECL_BASE_CONSTRUCTOR_P (NODE) \
|| DECL_BASE_DESTRUCTOR_P (NODE)))
using a twos-complement negated operand. */
#define TREE_NEGATED_INT(NODE) TREE_LANG_FLAG_0 (INTEGER_CST_CHECK (NODE))
-/* 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))
-
/* [class.virtual]
A class that declares or inherits a virtual function is called a
/* Nonzero if this class has a virtual function table pointer. */
#define TYPE_CONTAINS_VPTR_P(NODE) \
- (TYPE_POLYMORPHIC_P (NODE) \
- || TYPE_USES_VIRTUAL_BASECLASSES (NODE))
+ (TYPE_POLYMORPHIC_P (NODE) || CLASSTYPE_VBASECLASSES (NODE))
/* This flag is true of a local VAR_DECL if it was declared in a for
statement, but we are no longer in the scope of the for. */
if (max_bases > 1)
{
- 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_FOR_JAVA (ref))
error ("Java class '%T' cannot have multiple bases", ref);
}
if (max_vbases)
{
CLASSTYPE_VBASECLASSES (ref) = VEC_alloc (tree, max_vbases);
- TYPE_USES_VIRTUAL_BASECLASSES (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 (TYPE_FOR_JAVA (ref))
error ("Java class '%T' cannot have virtual bases", ref);
TYPE_HAS_ARRAY_NEW_OPERATOR (ref)
|= TYPE_HAS_ARRAY_NEW_OPERATOR (basetype);
TYPE_GETS_DELETE (ref) |= TYPE_GETS_DELETE (basetype);
- TYPE_USES_MULTIPLE_INHERITANCE (ref)
- |= TYPE_USES_MULTIPLE_INHERITANCE (basetype);
- TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref)
- |= TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (basetype);
TYPE_HAS_CONVERSION (ref) |= TYPE_HAS_CONVERSION (basetype);
}
{
int flags = LOOKUP_NORMAL|LOOKUP_DESTRUCTOR;
tree rval;
+ bool has_vbases = (TREE_CODE (type) == RECORD_TYPE
+ && CLASSTYPE_VBASECLASSES (type));
if (TREE_CODE (type) == ARRAY_TYPE)
rval = decl;
}
/* Optimize for space over speed here. */
- if (! TYPE_USES_VIRTUAL_BASECLASSES (type)
- || flag_expensive_optimizations)
+ if (!has_vbases || flag_expensive_optimizations)
flags |= LOOKUP_NONVIRTUAL;
rval = build_delete (TREE_TYPE (rval), rval,
sfk_complete_destructor, flags, 0);
- if (TYPE_USES_VIRTUAL_BASECLASSES (type)
- && ! TYPE_HAS_DESTRUCTOR (type))
+ if (has_vbases && !TYPE_HAS_DESTRUCTOR (type))
rval = build_compound_expr (rval, build_vbase_delete (type, decl));
return rval;
/* We don't need an in-charge parameter for constructors that don't
have virtual bases. */
if (DECL_CONSTRUCTOR_P (fn)
- && !TYPE_USES_VIRTUAL_BASECLASSES (DECL_CONTEXT (fn)))
+ && !CLASSTYPE_VBASECLASSES (DECL_CONTEXT (fn)))
return;
arg_types = TYPE_ARG_TYPES (TREE_TYPE (fn));
/* If this is a subobject constructor or destructor, our caller will
pass us a pointer to our VTT. */
- if (TYPE_USES_VIRTUAL_BASECLASSES (DECL_CONTEXT (fn)))
+ if (CLASSTYPE_VBASECLASSES (DECL_CONTEXT (fn)))
{
parm = build_artificial_parm (vtt_parm_identifier, vtt_parm_type);
if (!direct_binfo && !virtual_binfo)
{
- if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
+ if (CLASSTYPE_VBASECLASSES (current_class_type))
error ("type `%D' is not a direct or virtual base of `%T'",
name, current_class_type);
else
VEC (tree) *vbases;
/* Run destructors for all virtual baseclasses. */
- if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
+ if (CLASSTYPE_VBASECLASSES (current_class_type))
{
tree cond = (condition_conversion
(build2 (BIT_AND_EXPR, integer_type_node,
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_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)
- = TYPE_USES_VIRTUAL_BASECLASSES (pattern);
TYPE_PACKED (type) = TYPE_PACKED (pattern);
TYPE_ALIGN (type) = TYPE_ALIGN (pattern);
TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (pattern);
fputs (" delete[]", file);
if (TYPE_HAS_ASSIGN_REF (node))
fputs (" this=(X&)", file);
- if (TYPE_USES_MULTIPLE_INHERITANCE (node))
- fputs (" uses-multiple-inheritance", file);
if (TREE_CODE (node) == RECORD_TYPE)
{
if (tail)
{
- if (TYPE_USES_VIRTUAL_BASECLASSES (type))
- {
- sorry ("initializer list for object of class with virtual base classes");
- return error_mark_node;
- }
-
- 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;
- }
-
- if (TYPE_POLYMORPHIC_P (type))
- {
- sorry ("initializer list for object using virtual functions");
- return error_mark_node;
- }
+ gcc_assert (!CLASSTYPE_VBASECLASSES (type));
+ gcc_assert (!TYPE_BINFO (type)
+ || !BINFO_N_BASE_BINFOS (TYPE_BINFO (type)));
+ gcc_assert (!TYPE_POLYMORPHIC_P (type));
}
for (field = TYPE_FIELDS (type); field;