+2000-01-24 Nathan Sidwell <sidwell@codesourcery.com>
+
+ * cp-tree.h (CPTI_TP_DESC_TYPE, CPTI_ACCESS_MODE_TYPE,
+ CPTI_USER_DESC_TYPE, CPTI_CLASS_DESC_TYPE, CPTI_ATTR_DESC_TYPE,
+ CPTI_PTMF_DESC_TYPE): Remove cp_tree_index enumerations.
+ (CPTI_TI_DESC_TYPE, CPTI_REF_DESC_TYPE, CPTI_ARY_DESC_TYPE,
+ CPTI_ENUM_DESC_TYPE, CPTI_CLASS_DESC_TYPE, CPTI_SI_CLASS_DESC_TYPE,
+ CPTI_VMI_CLASS_DESC_TYPE, CPTI_BASE_DESC_TYPE): New enumerations.
+ (CPTI_TINFO_FN_ID, CPTI_TINFO_FN_TYPE): Rename to ...
+ (CPTI_TINFO_DECL_ID, CPTI_TINFO_DECL_TYPE): ... here.
+ (CPTI_TINFO_VAR_ID): New enumeration.
+ (__tp_desc_type_node, __access_mode_type_node,
+ __bltn_desc_type_node, __user_desc_type_node,
+ __class_desc_type_node, __ptr_desc_type_node,
+ __attr_desc_type_node, __func_desc_type_node,
+ __ptmf_desc_type_node, __ptmd_desc_type_node): Remove #defines.
+ (ti_desc_type_node, bltn_desc_type_node, ptr_desc_type_node,
+ ref_desc_type_node, ary_desc_type_node, func_desc_type_node,
+ enum_desc_type_node, class_desc_type_node,
+ si_class_desc_type_node, vmi_class_desc_type_node,
+ ptmd_desc_type_node, base_desc_type_node): New #defines.
+ (tinfo_fn_id, tinfo_fn_type): Rename to ...
+ (tinfo_decl_id, tinfo_decl_type): ... here. Adjust.
+ (tinfo_var_id): New enumeration.
+ (DECL_TINFO_FN_P): Augment comment.
+ * decl.c (cp_global_trees): Adjust documentation.
+ * rtti.c (init_rtti_processing): Adjust for tinfo_decl_id,
+ tinfo_decl_type and tinfo_var_id.
+ (get_tinfo_decl_dynamic): Adjust for tinfo_decl_type.
+ (build_typeid): Remove unused variable.
+ (get_tinfo_var): Use tinfo_var_id.
+ (tinfo_name): New static function.
+ (get_tinfo_decl): Adjust for tinfo_decl_id and tinfo_decl_type.
+ (tinfo_from_decl): Likewise.
+ (get_base_offset): New static function, broken out of
+ expand_class_desc.
+ (expand_si_desc): Use tinfo_name.
+ (expand_class_desc): Likewise. Lose local static variable.
+ Use base_desc_type_node. Use get_base_offset.
+ (expand_ptr_desc): Use tinfo_name.
+ (expand_attr_desc): Likewise.
+ (expand_generic_desc): Likewise.
+
+ * tinfo.cc (__GXX_ABI_VERSION): Test value and existance.
+ * tinfo.h (__GXX_ABI_VERSION): Test value and existance.
+
2000-01-23 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (__eprintf): Remove declaration.
CPTI_DELTA_TYPE,
CPTI_CLEANUP_TYPE,
- CPTI_TP_DESC_TYPE,
- CPTI_ACCESS_MODE_TYPE,
+ CPTI_TI_DESC_TYPE,
CPTI_BLTN_DESC_TYPE,
- CPTI_USER_DESC_TYPE,
- CPTI_CLASS_DESC_TYPE,
CPTI_PTR_DESC_TYPE,
- CPTI_ATTR_DESC_TYPE,
+ CPTI_REF_DESC_TYPE,
+ CPTI_ARY_DESC_TYPE,
CPTI_FUNC_DESC_TYPE,
- CPTI_PTMF_DESC_TYPE,
+ CPTI_ENUM_DESC_TYPE,
+ CPTI_CLASS_DESC_TYPE,
+ CPTI_SI_CLASS_DESC_TYPE,
+ CPTI_VMI_CLASS_DESC_TYPE,
CPTI_PTMD_DESC_TYPE,
+ CPTI_BASE_DESC_TYPE,
CPTI_CLASS_STAR_TYPE,
CPTI_CLASS_TYPE,
CPTI_VTBL_PTR_TYPE,
CPTI_STD,
CPTI_TYPE_INFO_TYPE,
- CPTI_TINFO_FN_ID,
- CPTI_TINFO_FN_TYPE,
+ CPTI_TINFO_DECL_ID,
+ CPTI_TINFO_DECL_TYPE,
+ CPTI_TINFO_VAR_ID,
CPTI_ABORT_FNDECL,
CPTI_GLOBAL_DELETE_FNDECL,
#define wchar_decl_node cp_global_trees[CPTI_WCHAR_DECL]
#define vtable_entry_type cp_global_trees[CPTI_VTABLE_ENTRY_TYPE]
#define delta_type_node cp_global_trees[CPTI_DELTA_TYPE]
-#define __tp_desc_type_node cp_global_trees[CPTI_TP_DESC_TYPE]
-#define __access_mode_type_node cp_global_trees[CPTI_ACCESS_MODE_TYPE]
-#define __bltn_desc_type_node cp_global_trees[CPTI_BLTN_DESC_TYPE]
-#define __user_desc_type_node cp_global_trees[CPTI_USER_DESC_TYPE]
-#define __class_desc_type_node cp_global_trees[CPTI_CLASS_DESC_TYPE]
-#define __ptr_desc_type_node cp_global_trees[CPTI_PTR_DESC_TYPE]
-#define __attr_desc_type_node cp_global_trees[CPTI_ATTR_DESC_TYPE]
-#define __func_desc_type_node cp_global_trees[CPTI_FUNC_DESC_TYPE]
-#define __ptmf_desc_type_node cp_global_trees[CPTI_PTMF_DESC_TYPE]
-#define __ptmd_desc_type_node cp_global_trees[CPTI_PTMD_DESC_TYPE]
+
+#define ti_desc_type_node cp_global_trees[CPTI_TI_DESC_TYPE]
+#define bltn_desc_type_node cp_global_trees[CPTI_BLTN_DESC_TYPE]
+#define ptr_desc_type_node cp_global_trees[CPTI_PTR_DESC_TYPE]
+#define ref_desc_type_node cp_global_trees[CPTI_REF_DESC_TYPE]
+#define ary_desc_type_node cp_global_trees[CPTI_ARY_DESC_TYPE]
+#define func_desc_type_node cp_global_trees[CPTI_FUNC_DESC_TYPE]
+#define enum_desc_type_node cp_global_trees[CPTI_ENUM_DESC_TYPE]
+#define class_desc_type_node cp_global_trees[CPTI_CLASS_DESC_TYPE]
+#define si_class_desc_type_node cp_global_trees[CPTI_SI_CLASS_DESC_TYPE]
+#define vmi_class_desc_type_node cp_global_trees[CPTI_VMI_CLASS_DESC_TYPE]
+#define ptmd_desc_type_node cp_global_trees[CPTI_PTMD_DESC_TYPE]
+#define base_desc_type_node cp_global_trees[CPTI_BASE_DESC_TYPE]
+
#define class_star_type_node cp_global_trees[CPTI_CLASS_STAR_TYPE]
#define class_type_node cp_global_trees[CPTI_CLASS_TYPE]
#define record_type_node cp_global_trees[CPTI_RECORD_TYPE]
#define vtbl_ptr_type_node cp_global_trees[CPTI_VTBL_PTR_TYPE]
#define std_node cp_global_trees[CPTI_STD]
#define type_info_type_node cp_global_trees[CPTI_TYPE_INFO_TYPE]
-#define tinfo_fn_id cp_global_trees[CPTI_TINFO_FN_ID]
-#define tinfo_fn_type cp_global_trees[CPTI_TINFO_FN_TYPE]
+#define tinfo_decl_id cp_global_trees[CPTI_TINFO_DECL_ID]
+#define tinfo_decl_type cp_global_trees[CPTI_TINFO_DECL_TYPE]
+#define tinfo_var_id cp_global_trees[CPTI_TINFO_VAR_ID]
#define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL]
#define global_delete_fndecl cp_global_trees[CPTI_GLOBAL_DELETE_FNDECL]
for an object with virtual baseclasses. */
#define DECL_CONSTRUCTOR_FOR_VBASE_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.constructor_for_vbase_attr)
-/* Non-zero for a FUNCTION_DECL that declares a type-info function. */
+/* Non-zero for a FUNCTION_DECL that declares a type-info function.
+ This only happens in the old abi. */
#define DECL_TINFO_FN_P(NODE) \
(TREE_CODE (NODE) == FUNCTION_DECL \
&& DECL_ARTIFICIAL (NODE) \
static tree build_headof PROTO((tree));
static tree get_tinfo_var PROTO((tree));
static tree ifnonnull PROTO((tree, tree));
+static tree tinfo_name PROTO((tree));
+static tree get_base_offset PROTO((tree, tree));
static tree build_dynamic_cast_1 PROTO((tree, tree));
static void expand_si_desc PROTO((tree, tree));
static void expand_class_desc PROTO((tree, tree));
(class_type_node, get_identifier ("type_info"), 1);
if (flag_honor_std)
pop_namespace ();
- tinfo_fn_id = get_identifier ("__tf");
- tinfo_fn_type = build_function_type
- (build_reference_type (build_qualified_type (type_info_type_node,
- TYPE_QUAL_CONST)),
- void_list_node);
+
+ tinfo_decl_id = get_identifier ("__tf");
+ tinfo_decl_type = build_function_type
+ (build_reference_type
+ (build_qualified_type
+ (type_info_type_node, TYPE_QUAL_CONST)),
+ void_list_node);
+ tinfo_var_id = get_identifier ("__ti");
}
/* Given a pointer to an object with at least one virtual table
t = build_vfn_ref ((tree *) 0, exp, integer_one_node);
else
t = build_vfn_ref ((tree *) 0, exp, integer_zero_node);
- TREE_TYPE (t) = build_pointer_type (tinfo_fn_type);
+ TREE_TYPE (t) = build_pointer_type (tinfo_decl_type);
return t;
}
tree exp;
{
tree cond = NULL_TREE;
- tree type;
int nonnull = 0;
if (! flag_rtti)
get_tinfo_var (type)
tree type;
{
- tree tname = build_overload_with_type (get_identifier ("__ti"), type);
+ tree tname = build_overload_with_type (tinfo_var_id, type);
tree arrtype;
int size;
return declare_global_var (tname, arrtype);
}
+/* Generate the NTBS name of a type. */
+static tree
+tinfo_name (type)
+ tree type;
+{
+ const char *name = build_overload_name (type, 1, 1);
+ tree name_string = combine_strings (build_string (strlen (name) + 1, name));
+ return name_string;
+}
+
/* Returns a decl for a function or variable which can be used to obtain a
type_info object for TYPE. The old-abi uses functions, the new-abi will
use the type_info object directly. You can take the address of the
- returned decl, to save the decl. To use the generator call
- tinfo_from_generator. You must arrange that the decl is mark_used, if
+ returned decl, to save the decl. To use the decl call
+ tinfo_from_decl. You must arrange that the decl is mark_used, if
actually use it --- decls in vtables are only used if the vtable is
output. */
type = build_function_type (TREE_TYPE (type),
TREE_CHAIN (TYPE_ARG_TYPES (type)));
- name = build_overload_with_type (tinfo_fn_id, type);
+ name = build_overload_with_type (tinfo_decl_id, type);
if (IDENTIFIER_GLOBAL_VALUE (name))
return IDENTIFIER_GLOBAL_VALUE (name);
- d = build_lang_decl (FUNCTION_DECL, name, tinfo_fn_type);
+ d = build_lang_decl (FUNCTION_DECL, name, tinfo_decl_type);
DECL_EXTERNAL (d) = 1;
TREE_PUBLIC (d) = 1;
DECL_ARTIFICIAL (d) = 1;
tinfo_from_decl (expr)
tree expr;
{
- tree t = build_call (expr, TREE_TYPE (tinfo_fn_type), NULL_TREE);
+ tree t = build_call (expr, TREE_TYPE (tinfo_decl_type), NULL_TREE);
return t;
}
result);
}
+/* Generate the constant expression describing where direct base BINFO
+ appears within the PARENT. How to interpret this expression depends on
+ details of the ABI, which the runtime must be aware of. */
+
+static tree
+get_base_offset (binfo, parent)
+ tree binfo;
+ tree parent;
+{
+ tree offset;
+
+ if (!TREE_VIA_VIRTUAL (binfo))
+ offset = BINFO_OFFSET (binfo);
+ else if (!vbase_offsets_in_vtable_p ())
+ {
+ tree t = BINFO_TYPE (binfo);
+ const char *name;
+ tree field;
+
+ FORMAT_VBASE_NAME (name, t);
+ field = lookup_field (parent, get_identifier (name), 0, 0);
+ offset = size_binop (FLOOR_DIV_EXPR,
+ DECL_FIELD_BITPOS (field),
+ size_int (BITS_PER_UNIT));
+ offset = convert (sizetype, offset);
+ }
+ else
+ {
+ /* Under the new ABI, we store the vtable offset at which
+ the virtual base offset can be found. */
+ tree vbase = BINFO_FOR_VBASE (BINFO_TYPE (binfo), parent);
+ offset = convert (sizetype, BINFO_VPTR_FIELD (vbase));
+ }
+ return offset;
+}
+
/* Execute a dynamic cast, as described in section 5.2.6 of the 9/93 working
paper. */
tree type;
{
tree t, elems, fn;
- const char *name = build_overload_name (type, 1, 1);
- tree name_string = combine_strings (build_string (strlen (name)+1, name));
+ tree name_string = tinfo_name (type);
type = BINFO_TYPE (TREE_VEC_ELT (TYPE_BINFO_BASETYPES (type), 0));
finish_expr_stmt (get_typeid_1 (type));
{
tree name_string;
tree fn, tmp;
- const char *name;
int i = CLASSTYPE_N_BASECLASSES (type);
int base_cnt = 0;
#endif
tree base, elems, access, offset, isvir;
tree elt, elts = NULL_TREE;
- static tree base_info_type_node;
- if (base_info_type_node == NULL_TREE)
+ if (base_desc_type_node == NULL_TREE)
{
tree fields [4];
/* A reasonably close approximation of __class_type_info::base_info */
- base_info_type_node = make_aggr_type (RECORD_TYPE);
+ base_desc_type_node = make_aggr_type (RECORD_TYPE);
/* Actually const __user_type_info * */
fields [0] = build_lang_decl
DECL_BIT_FIELD (fields[3]) = 1;
DECL_FIELD_SIZE (fields[3]) = 2;
- finish_builtin_type (base_info_type_node, "__base_info", fields,
+ finish_builtin_type (base_desc_type_node, "__base_info", fields,
3, ptr_type_node);
}
finish_expr_stmt (get_typeid_1 (BINFO_TYPE (binfo)));
base = decay_conversion (get_tinfo_var (BINFO_TYPE (binfo)));
-
- if (TREE_VIA_VIRTUAL (binfo))
- {
- if (!vbase_offsets_in_vtable_p ())
- {
- tree t = BINFO_TYPE (binfo);
- const char *name;
- tree field;
-
- FORMAT_VBASE_NAME (name, t);
- field = lookup_field (type, get_identifier (name), 0, 0);
- offset = size_binop (FLOOR_DIV_EXPR,
- DECL_FIELD_BITPOS (field),
- size_int (BITS_PER_UNIT));
- offset = convert (sizetype, offset);
- }
- else
- {
- /* Under the new ABI, we store the vtable offset at which
- the virtual base offset can be found. */
- tree vbase = BINFO_FOR_VBASE (BINFO_TYPE (binfo), type);
- offset = convert (sizetype, BINFO_VPTR_FIELD (vbase));
- }
- }
- else
- offset = BINFO_OFFSET (binfo);
-
+ offset = get_base_offset (binfo, type);
+
if (TREE_VIA_PUBLIC (binfo))
access = access_public_node;
else if (TREE_VIA_PROTECTED (binfo))
isvir = boolean_false_node;
elt = build
- (CONSTRUCTOR, base_info_type_node, NULL_TREE, tree_cons
+ (CONSTRUCTOR, base_desc_type_node, NULL_TREE, tree_cons
(NULL_TREE, base, tree_cons
(NULL_TREE, offset, tree_cons
(NULL_TREE, isvir, tree_cons
}
#endif
- name = build_overload_name (type, 1, 1);
- name_string = combine_strings (build_string (strlen (name)+1, name));
+ name_string = tinfo_name (type);
{
- tree arrtype = build_array_type (base_info_type_node, NULL_TREE);
+ tree arrtype = build_array_type (base_desc_type_node, NULL_TREE);
elts = build (CONSTRUCTOR, arrtype, NULL_TREE, elts);
TREE_HAS_CONSTRUCTOR (elts) = TREE_CONSTANT (elts)
= TREE_STATIC (elts) = 1;
tmp = tree_cons
(NULL_TREE, ptr_type_node, tree_cons
(NULL_TREE, const_string_type_node, tree_cons
- (NULL_TREE, build_pointer_type (base_info_type_node), tree_cons
+ (NULL_TREE, build_pointer_type (base_desc_type_node), tree_cons
(NULL_TREE, sizetype, void_list_node))));
tmp = build_function_type (void_type_node, tmp);
tree type;
{
tree t, elems, fn;
- const char *name = build_overload_name (type, 1, 1);
- tree name_string = combine_strings (build_string (strlen (name)+1, name));
+ tree name_string = tinfo_name (type);
type = TREE_TYPE (type);
finish_expr_stmt (get_typeid_1 (type));
tree type;
{
tree elems, t, fn;
- const char *name = build_overload_name (type, 1, 1);
- tree name_string = combine_strings (build_string (strlen (name)+1, name));
+ tree name_string = tinfo_name (type);
tree attrval = build_int_2 (TYPE_QUALS (type), 0);
finish_expr_stmt (get_typeid_1 (TYPE_MAIN_VARIANT (type)));
tree type;
const char *fnname;
{
- const char *name = build_overload_name (type, 1, 1);
- tree name_string = combine_strings (build_string (strlen (name)+1, name));
+ tree name_string = tinfo_name (type);
tree elems = tree_cons
(NULL_TREE, decay_conversion (tdecl), tree_cons
(NULL_TREE, decay_conversion (name_string), NULL_TREE));