diff options
Diffstat (limited to 'contrib/gcc/cp/rtti.c')
-rw-r--r-- | contrib/gcc/cp/rtti.c | 87 |
1 files changed, 46 insertions, 41 deletions
diff --git a/contrib/gcc/cp/rtti.c b/contrib/gcc/cp/rtti.c index fbb37fe..7b4a248 100644 --- a/contrib/gcc/cp/rtti.c +++ b/contrib/gcc/cp/rtti.c @@ -62,13 +62,13 @@ Boston, MA 02111-1307, USA. */ /* Accessors for the type_info objects. We need to remember several things about each of the type_info types. The global tree nodes such as bltn_desc_type_node are TREE_LISTs, and these macros are used to access - the required information. */ -/* The RECORD_TYPE of a type_info derived class. */ + the required information. */ +/* The RECORD_TYPE of a type_info derived class. */ #define TINFO_PSEUDO_TYPE(NODE) TREE_TYPE (NODE) /* The VAR_DECL of the vtable for the type_info derived class. - This is only filled in at the end of the translation. */ + This is only filled in at the end of the translation. */ #define TINFO_VTABLE_DECL(NODE) TREE_VALUE (NODE) -/* The IDENTIFIER_NODE naming the real class. */ +/* The IDENTIFIER_NODE naming the real class. */ #define TINFO_REAL_NAME(NODE) TREE_PURPOSE (NODE) static tree build_headof PARAMS((tree)); @@ -109,8 +109,9 @@ void init_rtti_processing () { push_namespace (std_identifier); - type_info_type_node = xref_tag - (class_type_node, get_identifier ("type_info"), 1); + type_info_type_node + = xref_tag (class_type, get_identifier ("type_info"), + /*attributes=*/NULL_TREE, 1); pop_namespace (); type_info_ptr_type = build_pointer_type @@ -142,7 +143,7 @@ build_headof (exp) exp = save_expr (exp); /* The offset-to-top field is at index -2 from the vptr. */ - index = build_int_2 (-2, -1); + index = build_int_2 (-2 * TARGET_VTABLE_DATA_ENTRY_DISTANCE, -1); offset = build_vtbl_ref (build_indirect_ref (exp, NULL), index); @@ -166,7 +167,7 @@ throw_bad_cast () fn = push_throw_library_fn (fn, build_function_type (ptr_type_node, void_list_node)); - return build_call (fn, NULL_TREE); + return build_cxx_call (fn, NULL_TREE, NULL_TREE); } static tree @@ -182,7 +183,7 @@ throw_bad_typeid () fn = push_throw_library_fn (fn, t); } - return build_call (fn, NULL_TREE); + return build_cxx_call (fn, NULL_TREE, NULL_TREE); } /* Return a pointer to type_info function associated with the expression EXP. @@ -221,7 +222,7 @@ get_tinfo_decl_dynamic (exp) tree index; /* The RTTI information is at index -1. */ - index = integer_minus_one_node; + index = build_int_2 (-1 * TARGET_VTABLE_DATA_ENTRY_DISTANCE, -1); t = build_vtbl_ref (exp, index); TREE_TYPE (t) = type_info_ptr_type; return t; @@ -298,7 +299,7 @@ tinfo_name (type) tree name_string; name = mangle_type_string (type); - name_string = combine_strings (build_string (strlen (name) + 1, name)); + name_string = fix_string_type (build_string (strlen (name) + 1, name)); return name_string; } @@ -351,9 +352,8 @@ get_tinfo_decl (type) DECL_EXTERNAL (d) = 1; SET_DECL_ASSEMBLER_NAME (d, name); DECL_COMDAT (d) = 1; - cp_finish_decl (d, NULL_TREE, NULL_TREE, 0); - pushdecl_top_level (d); + pushdecl_top_level_and_finish (d, NULL_TREE); if (CLASS_TYPE_P (type)) CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type)) = d; @@ -633,8 +633,9 @@ build_dynamic_cast_1 (type, expr) const char *name; push_nested_namespace (ns); - tinfo_ptr = xref_tag (class_type_node, + tinfo_ptr = xref_tag (class_type, get_identifier ("__class_type_info"), + /*attributes=*/NULL_TREE, 1); tinfo_ptr = build_pointer_type @@ -651,7 +652,7 @@ build_dynamic_cast_1 (type, expr) pop_nested_namespace (ns); dynamic_cast_node = dcast_fn; } - result = build_call (dcast_fn, elems); + result = build_cxx_call (dcast_fn, elems, elems); if (tc == REFERENCE_TYPE) { @@ -695,8 +696,7 @@ qualifier_flags (type) tree type; { int flags = 0; - /* we want the qualifiers on this type, not any array core, it might have */ - int quals = TYPE_QUALS (type); + int quals = cp_type_quals (type); if (quals & TYPE_QUAL_CONST) flags |= 1; @@ -707,7 +707,7 @@ qualifier_flags (type) return flags; } -/* Return non-zero, if the pointer chain TYPE ends at an incomplete type, or +/* Return nonzero, if the pointer chain TYPE ends at an incomplete type, or contains a pointer to member of an incomplete class. */ static int @@ -767,8 +767,7 @@ tinfo_base_init (desc, target) SET_DECL_ASSEMBLER_NAME (name_decl, mangle_typeinfo_string_for_type (target)); DECL_INITIAL (name_decl) = name_string; - cp_finish_decl (name_decl, name_string, NULL_TREE, 0); - pushdecl_top_level (name_decl); + pushdecl_top_level_and_finish (name_decl, name_string); } vtable_ptr = TINFO_VTABLE_DECL (desc); @@ -777,9 +776,10 @@ tinfo_base_init (desc, target) tree real_type; push_nested_namespace (abi_node); - real_type = xref_tag (class_type_node, TINFO_REAL_NAME (desc), 1); + real_type = xref_tag (class_type, TINFO_REAL_NAME (desc), + /*attributes=*/NULL_TREE, 1); pop_nested_namespace (abi_node); - + if (!COMPLETE_TYPE_P (real_type)) { /* We never saw a definition of this type, so we need to @@ -796,7 +796,7 @@ tinfo_base_init (desc, target) vtable_ptr = build (PLUS_EXPR, TREE_TYPE (vtable_ptr), vtable_ptr, size_binop (MULT_EXPR, - size_int (2), + size_int (2 * TARGET_VTABLE_DATA_ENTRY_DISTANCE), TYPE_SIZE_UNIT (vtable_entry_type))); TREE_CONSTANT (vtable_ptr) = 1; @@ -932,7 +932,7 @@ dfs_class_hint_mark (binfo, data) return NULL_TREE; }; -/* Clear the base's dfs marks, after searching for duplicate bases. */ +/* Clear the base's dfs marks, after searching for duplicate bases. */ static tree dfs_class_hint_unmark (binfo, data) @@ -986,7 +986,7 @@ class_initializer (desc, target, trail) return init; } -/* Returns non-zero if the typeinfo for type should be placed in +/* Returns nonzero if the typeinfo for type should be placed in the runtime library. */ static int @@ -1015,7 +1015,7 @@ typeinfo_in_lib_p (type) } /* Generate the initializer for the type info describing - TYPE. VAR_DESC is a . NON_PUBLIC_P is set non-zero, if the VAR_DECL + TYPE. VAR_DESC is a . NON_PUBLIC_P is set nonzero, if the VAR_DECL should not be exported from this object file. This should only be called at the end of translation, when we know that no further types will be completed. */ @@ -1105,15 +1105,17 @@ get_pseudo_ti_init (type, var_desc, non_public_p) base_init = tree_cons (NULL_TREE, offset, base_init); base_init = tree_cons (NULL_TREE, tinfo, base_init); base_init = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, base_init); + TREE_HAS_CONSTRUCTOR (base_init) = 1; base_inits = tree_cons (NULL_TREE, base_init, base_inits); } base_inits = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, base_inits); + TREE_HAS_CONSTRUCTOR (base_inits) = 1; base_inits = tree_cons (NULL_TREE, base_inits, NULL_TREE); /* Prepend the number of bases. */ base_inits = tree_cons (NULL_TREE, build_int_2 (nbases, 0), base_inits); - /* Prepend the hint flags. */ + /* Prepend the hint flags. */ base_inits = tree_cons (NULL_TREE, build_int_2 (hint, 0), base_inits); @@ -1155,24 +1157,24 @@ create_pseudo_type_info VPARAMS((const char *real_name, int ident, ...)) VA_FIXEDARG (ap, const char *, real_name); VA_FIXEDARG (ap, int, ident); - /* Generate the pseudo type name. */ + /* Generate the pseudo type name. */ pseudo_name = (char *)alloca (strlen (real_name) + 30); strcpy (pseudo_name, real_name); strcat (pseudo_name, "_pseudo"); if (ident) sprintf (pseudo_name + strlen (pseudo_name), "%d", ident); - /* First field is the pseudo type_info base class. */ + /* First field is the pseudo type_info base class. */ fields[0] = build_decl (FIELD_DECL, NULL_TREE, ti_desc_type_node); /* Now add the derived fields. */ for (ix = 0; (field_decl = va_arg (ap, tree));) fields[++ix] = field_decl; - /* Create the pseudo type. */ + /* Create the pseudo type. */ pseudo_type = make_aggr_type (RECORD_TYPE); finish_builtin_type (pseudo_type, pseudo_name, fields, ix, ptr_type_node); - TYPE_HAS_CONSTRUCTOR (pseudo_type) = 1; + CLASSTYPE_AS_BASE (pseudo_type) = pseudo_type; result = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); TINFO_REAL_NAME (result) = get_identifier (real_name); @@ -1207,7 +1209,8 @@ get_pseudo_ti_desc (type) return ptm_desc_type_node; else if (!COMPLETE_TYPE_P (type)) { - my_friendly_assert (at_eof, 20020609); + if (!at_eof) + cxx_incomplete_type_error (NULL_TREE, type); return class_desc_type_node; } else if (!CLASSTYPE_N_BASECLASSES (type)) @@ -1222,7 +1225,7 @@ get_pseudo_ti_desc (type) && TREE_PUBLIC (base_binfo) && !TREE_VIA_VIRTUAL (base_binfo) && integer_zerop (BINFO_OFFSET (base_binfo))) - /* single non-virtual public. */ + /* single non-virtual public. */ return si_class_desc_type_node; else { @@ -1295,7 +1298,7 @@ create_tinfo_types () ("__fundamental_type_info", 0, NULL); - /* Array, function and enum type_info. No additional fields. */ + /* Array, function and enum type_info. No additional fields. */ ary_desc_type_node = create_pseudo_type_info ("__array_type_info", 0, NULL); @@ -1319,7 +1322,7 @@ create_tinfo_types () NULL); /* Base class internal helper. Pointer to base type, offset to base, - flags. */ + flags. */ { tree fields[2]; @@ -1331,12 +1334,12 @@ create_tinfo_types () TYPE_HAS_CONSTRUCTOR (base_desc_type_node) = 1; } - /* General hierarchy is created as necessary in this vector. */ + /* General hierarchy is created as necessary in this vector. */ vmi_class_desc_type_node = make_tree_vec (10); /* Pointer type_info. Adds two fields, qualification mask and pointer to the pointed to type. This is really a descendant of - __pbase_type_info. */ + __pbase_type_info. */ ptr_desc_type_node = create_pseudo_type_info ("__pointer_type_info", 0, build_decl (FIELD_DECL, NULL_TREE, integer_type_node), @@ -1382,8 +1385,10 @@ emit_support_tinfos () tree bltn_type, dtor; push_nested_namespace (abi_node); - bltn_type = xref_tag (class_type_node, - get_identifier ("__fundamental_type_info"), 1); + bltn_type = xref_tag (class_type, + get_identifier ("__fundamental_type_info"), + /*attributes=*/NULL_TREE, + 1); pop_nested_namespace (abi_node); if (!COMPLETE_TYPE_P (bltn_type)) return; @@ -1413,7 +1418,7 @@ emit_support_tinfos () } } -/* Return non-zero, iff T is a type_info variable which has not had a +/* Return nonzero, iff T is a type_info variable which has not had a definition emitted for it. */ int @@ -1470,7 +1475,7 @@ emit_tinfo_decl (decl_ptr, data) DECL_INITIAL (decl) = var_init; cp_finish_decl (decl, var_init, NULL_TREE, 0); - /* cp_finish_decl will have dealt with linkage. */ + /* cp_finish_decl will have dealt with linkage. */ /* Say we've dealt with it. */ TREE_TYPE (DECL_NAME (decl)) = NULL_TREE; |