/* The IDENTIFIER_NODE naming the real class. */
#define TINFO_REAL_NAME(NODE) TREE_PURPOSE (NODE)
-/* A varray of all tinfo decls that haven't yet been emitted. */
-varray_type unemitted_tinfo_decls;
+/* A vector of all tinfo decls that haven't yet been emitted. */
+VEC (tree) *unemitted_tinfo_decls;
static tree build_headof (tree);
static tree ifnonnull (tree, tree);
static bool target_incomplete_p (tree);
static tree tinfo_base_init (tree, tree);
static tree generic_initializer (tree, tree);
-static tree dfs_class_hint_mark (tree, void *);
-static tree dfs_class_hint_unmark (tree, void *);
-static int class_hint_flags (tree);
static tree class_initializer (tree, tree, tree);
static tree create_pseudo_type_info (const char *, int, ...);
static tree get_pseudo_ti_init (tree, tree);
type_info_ptr_type = build_pointer_type (const_type_info_type);
type_info_ref_type = build_reference_type (const_type_info_type);
- VARRAY_TREE_INIT (unemitted_tinfo_decls, 10, "RTTI decls");
-
+ unemitted_tinfo_decls = VEC_alloc (tree, 124);
+
create_tinfo_types ();
}
tree offset;
tree index;
- my_friendly_assert (TREE_CODE (type) == POINTER_TYPE, 20000112);
+ gcc_assert (TREE_CODE (type) == POINTER_TYPE);
type = TREE_TYPE (type);
if (!TYPE_POLYMORPHIC_P (type))
exp = save_expr (exp);
/* The offset-to-top field is at index -2 from the vptr. */
- index = build_int_2 (-2 * TARGET_VTABLE_DATA_ENTRY_DISTANCE, -1);
+ index = build_int_cst (NULL_TREE,
+ -2 * TARGET_VTABLE_DATA_ENTRY_DISTANCE);
offset = build_vtbl_ref (build_indirect_ref (exp, NULL), index);
type = build_qualified_type (ptr_type_node,
cp_type_quals (TREE_TYPE (exp)));
- return build (PLUS_EXPR, type, exp,
- convert_to_integer (ptrdiff_type_node, offset));
+ return build2 (PLUS_EXPR, type, exp,
+ convert_to_integer (ptrdiff_type_node, offset));
}
/* Get a bad_cast node for the program to throw...
tree index;
/* The RTTI information is at index -1. */
- index = build_int_2 (-1 * TARGET_VTABLE_DATA_ENTRY_DISTANCE, -1);
+ index = build_int_cst (NULL_TREE,
+ -1 * TARGET_VTABLE_DATA_ENTRY_DISTANCE);
t = build_vtbl_ref (exp, index);
t = convert (type_info_ptr_type, t);
}
{
tree bad = throw_bad_typeid ();
- exp = build (COND_EXPR, TREE_TYPE (exp), cond, exp, bad);
+ exp = build3 (COND_EXPR, TREE_TYPE (exp), cond, exp, bad);
}
return exp;
if (COMPLETE_TYPE_P (type)
&& TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
{
- error ("cannot create type information for type `%T' because its size is variable",
+ error ("cannot create type information for type %qT because "
+ "its size is variable",
type);
return error_mark_node;
}
pushdecl_top_level_and_finish (d, NULL_TREE);
/* Add decl to the global array of tinfo decls. */
- my_friendly_assert (unemitted_tinfo_decls != 0, 20030312);
- VARRAY_PUSH_TREE (unemitted_tinfo_decls, d);
+ VEC_safe_push (tree, unemitted_tinfo_decls, d);
}
return d;
static tree
ifnonnull (tree test, tree result)
{
- return build (COND_EXPR, TREE_TYPE (result),
- build (EQ_EXPR, boolean_type_node, test, integer_zero_node),
- cp_convert (TREE_TYPE (result), integer_zero_node),
- result);
+ return build3 (COND_EXPR, TREE_TYPE (result),
+ build2 (EQ_EXPR, boolean_type_node, test, integer_zero_node),
+ cp_convert (TREE_TYPE (result), integer_zero_node),
+ result);
}
/* Execute a dynamic cast, as described in section 5.2.6 of the 9/93 working
&& TREE_CODE (TREE_TYPE (old_expr)) == RECORD_TYPE)
{
tree expr = throw_bad_cast ();
- warning ("dynamic_cast of `%#D' to `%#T' can never succeed",
- old_expr, type);
+ warning ("dynamic_cast of %q#D to %q#T can never succeed",
+ old_expr, type);
/* Bash it to the expected type. */
TREE_TYPE (expr) = type;
return expr;
if (TREE_CODE (op) == VAR_DECL
&& TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE)
{
- warning ("dynamic_cast of `%#D' to `%#T' can never succeed",
- op, type);
- retval = build_int_2 (0, 0);
- TREE_TYPE (retval) = type;
+ warning ("dynamic_cast of %q#D to %q#T can never succeed",
+ op, type);
+ retval = build_int_cst (type, 0);
return retval;
}
}
tree bad = throw_bad_cast ();
result = save_expr (result);
- return build (COND_EXPR, type, result, result, bad);
+ return build3 (COND_EXPR, type, result, result, bad);
}
/* Now back to the type we want from a void*. */
errstr = "source type is not polymorphic";
fail:
- error ("cannot dynamic_cast `%E' (of type `%#T') to type `%#T' (%s)",
- expr, exprtype, type, errstr);
+ error ("cannot dynamic_cast %qE (of type %q#T) to type %q#T (%s)",
+ expr, exprtype, type, errstr);
return error_mark_node;
}
vtable_ptr = build_unary_op (ADDR_EXPR, vtable_ptr, 0);
/* We need to point into the middle of the vtable. */
- vtable_ptr = build
+ vtable_ptr = build2
(PLUS_EXPR, TREE_TYPE (vtable_ptr), vtable_ptr,
size_binop (MULT_EXPR,
size_int (2 * TARGET_VTABLE_DATA_ENTRY_DISTANCE),
if (incomplete)
flags |= 8;
- init = tree_cons (NULL_TREE, build_int_2 (flags, 0), init);
+ init = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, flags), init);
init = tree_cons (NULL_TREE,
get_tinfo_ptr (TYPE_MAIN_VARIANT (to)),
init);
flags |= 0x8;
if (!COMPLETE_TYPE_P (klass))
flags |= 0x10;
- init = tree_cons (NULL_TREE, build_int_2 (flags, 0), init);
+ init = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, flags), init);
init = tree_cons (NULL_TREE,
get_tinfo_ptr (TYPE_MAIN_VARIANT (to)),
init);
return init;
}
-/* Check base BINFO to set hint flags in *DATA, which is really an int.
- We use CLASSTYPE_MARKED to tag types we've found as non-virtual bases and
- CLASSTYPE_MARKED2 to tag those which are virtual bases. Remember it is
- possible for a type to be both a virtual and non-virtual base. */
-
-static tree
-dfs_class_hint_mark (tree binfo, void *data)
-{
- tree basetype = BINFO_TYPE (binfo);
- int *hint = (int *) data;
-
- if (BINFO_VIRTUAL_P (binfo))
- {
- if (CLASSTYPE_MARKED (basetype))
- *hint |= 1;
- if (CLASSTYPE_MARKED2 (basetype))
- *hint |= 2;
- SET_CLASSTYPE_MARKED2 (basetype);
- }
- else
- {
- if (CLASSTYPE_MARKED (basetype) || CLASSTYPE_MARKED2 (basetype))
- *hint |= 1;
- SET_CLASSTYPE_MARKED (basetype);
- }
- return NULL_TREE;
-}
-
-/* Clear the base's dfs marks, after searching for duplicate bases. */
-
-static tree
-dfs_class_hint_unmark (tree binfo, void *data ATTRIBUTE_UNUSED)
-{
- tree basetype = BINFO_TYPE (binfo);
-
- CLEAR_CLASSTYPE_MARKED (basetype);
- CLEAR_CLASSTYPE_MARKED2 (basetype);
- return NULL_TREE;
-}
-
-/* Determine the hint flags describing the features of a class's hierarchy. */
-
-static int
-class_hint_flags (tree type)
-{
- int hint_flags = 0;
-
- dfs_walk (TYPE_BINFO (type), dfs_class_hint_mark, NULL, &hint_flags);
- dfs_walk (TYPE_BINFO (type), dfs_class_hint_unmark, NULL, NULL);
-
- return hint_flags;
-}
-
/* Return the CONSTRUCTOR expr for a type_info of class TYPE.
DESC provides information about the particular __class_type_info derivation,
which adds hint flags and TRAIL initializers to the type_info base. */
static tree
get_pseudo_ti_init (tree type, tree var_desc)
{
- my_friendly_assert (at_eof, 20021120);
+ gcc_assert (at_eof);
switch (TREE_CODE (type))
{
case OFFSET_TYPE:
}
else
{
- int hint = class_hint_flags (type);
+ int hint = ((CLASSTYPE_REPEATED_BASE_P (type) << 0)
+ | (CLASSTYPE_DIAMOND_SHAPED_P (type) << 1));
tree binfo = TYPE_BINFO (type);
int nbases = BINFO_N_BASE_BINFOS (binfo);
VEC (tree) *base_accesses = BINFO_BASE_ACCESSES (binfo);
/* Combine offset and flags into one field. */
offset = cp_build_binary_op (LSHIFT_EXPR, offset,
- build_int_2 (8, 0));
+ build_int_cst (NULL_TREE, 8));
offset = cp_build_binary_op (BIT_IOR_EXPR, offset,
- build_int_2 (flags, 0));
+ build_int_cst (NULL_TREE, flags));
base_init = tree_cons (NULL_TREE, offset, base_init);
base_init = tree_cons (NULL_TREE, tinfo, base_init);
base_init = build_constructor (NULL_TREE, base_init);
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);
+ build_int_cst (NULL_TREE, nbases),
+ base_inits);
/* Prepend the hint flags. */
base_inits = tree_cons (NULL_TREE,
- build_int_2 (hint, 0), base_inits);
+ build_int_cst (NULL_TREE, hint),
+ base_inits);
return class_initializer (var_desc, type, base_inits);
}
static void
create_tinfo_types (void)
{
- my_friendly_assert (!ti_desc_type_node, 20020609);
+ gcc_assert (!ti_desc_type_node);
push_nested_namespace (abi_node);
int in_library = typeinfo_in_lib_p (type);
tree var_desc, var_init;
- my_friendly_assert (DECL_TINFO_P (decl), 20030307);
+ gcc_assert (DECL_TINFO_P (decl));
if (in_library)
{