OSDN Git Service

* cp-tree.h (struct lang_type_header): Remove
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Sep 2004 15:39:00 +0000 (15:39 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Sep 2004 15:39:00 +0000 (15:39 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87808 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/init.c
gcc/cp/pt.c
gcc/cp/ptree.c
gcc/cp/typeck2.c

index 99f3f3e..f436ad9 100644 (file)
@@ -1,3 +1,39 @@
+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
index 1185608..c5761ec 100644 (file)
@@ -2179,7 +2179,7 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
 
   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,
@@ -5052,7 +5052,7 @@ build_special_member_call (tree instance, tree name, tree args,
      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;
index 4c8dee3..071cd80 100644 (file)
@@ -1405,11 +1405,7 @@ finish_struct_bits (tree t)
       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);
 
@@ -4126,15 +4122,11 @@ check_bases_and_members (tree 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));
@@ -4229,13 +4221,6 @@ create_vtable_ptr (tree t, tree* virtuals_p)
       /* 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;
     }
 
@@ -6780,7 +6765,7 @@ build_vtt_inits (tree binfo, tree t, tree* inits, tree* index)
   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
@@ -6897,7 +6882,7 @@ dfs_build_secondary_vptr_vtt_inits (tree binfo, void *data)
 
   /* 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;
 
@@ -7052,7 +7037,7 @@ accumulate_vtbl_inits (tree binfo,
   /* 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;
 
@@ -7411,7 +7396,7 @@ build_vbase_offset_vtbl_entries (tree binfo, vtbl_init_data* vid)
 
   /* 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;
index 433403c..19158e9 100644 (file)
@@ -53,7 +53,6 @@ struct diagnostic_context;
       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)
@@ -61,8 +60,7 @@ struct diagnostic_context;
       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)
@@ -960,10 +958,11 @@ struct lang_type_header GTY(())
   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
@@ -1159,17 +1158,6 @@ struct lang_type GTY(())
    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 */
@@ -1739,7 +1727,7 @@ struct lang_decl GTY(())
 /* 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)))
 
@@ -2262,11 +2250,6 @@ struct lang_decl GTY(())
    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
@@ -2275,8 +2258,7 @@ struct lang_decl GTY(())
 
 /* 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.  */
index fbd27ce..d486505 100644 (file)
@@ -9241,11 +9241,6 @@ xref_basetypes (tree ref, tree base_list)
 
   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);
     }
@@ -9253,10 +9248,6 @@ xref_basetypes (tree ref, tree base_list)
   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);
@@ -9309,10 +9300,6 @@ xref_basetypes (tree ref, tree base_list)
          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);
        }
 
@@ -10788,6 +10775,8 @@ cxx_maybe_build_cleanup (tree decl)
     {
       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;
@@ -10798,15 +10787,13 @@ cxx_maybe_build_cleanup (tree 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;
index c6b8f51..0c05a7a 100644 (file)
@@ -198,7 +198,7 @@ maybe_retrofit_in_chrg (tree fn)
   /* 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));
@@ -209,7 +209,7 @@ maybe_retrofit_in_chrg (tree 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);
 
index 0147881..58dac96 100644 (file)
@@ -1001,7 +1001,7 @@ expand_member_init (tree name)
 
       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
@@ -2855,7 +2855,7 @@ push_base_cleanups (void)
   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,
index 4d77a8d..42f652a 100644 (file)
@@ -5459,12 +5459,6 @@ instantiate_class_template (tree 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_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);
index 289cb19..3168241 100644 (file)
@@ -123,8 +123,6 @@ cxx_print_type (FILE *file, tree node, int indent)
     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)
     {
index 44f6483..089e155 100644 (file)
@@ -947,23 +947,10 @@ process_init_constructor (tree type, tree init, tree* elts)
 
       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;