/* RunTime Type Identification
- Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
Mostly written by Jason Merrill (jason@cygnus.com).
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-
#include "config.h"
#include "system.h"
#include "coretypes.h"
/* 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 ptr_initializer (tree, tree, bool *);
-static tree ptm_initializer (tree, tree, bool *);
-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, bool *);
+static tree get_pseudo_ti_init (tree, tree);
static tree get_pseudo_ti_desc (tree);
static void create_tinfo_types (void);
static bool typeinfo_in_lib_p (tree);
-static bool unemitted_tinfo_decl_p (tree);
static int doing_runtime = 0;
\f
push_namespace (std_identifier);
type_info_type_node
= xref_tag (class_type, get_identifier ("type_info"),
- /*attributes=*/NULL_TREE, true, false);
+ true, false);
pop_namespace ();
const_type_info_type = build_qualified_type (type_info_type_node,
TYPE_QUAL_CONST);
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...
fn = push_throw_library_fn (fn, build_function_type (ptr_type_node,
void_list_node));
- return build_cxx_call (fn, NULL_TREE, NULL_TREE);
+ return build_cxx_call (fn, NULL_TREE);
}
/* Return an expression for "__cxa_bad_typeid()". The expression
fn = push_throw_library_fn (fn, t);
}
- return convert_from_reference (build_cxx_call (fn, NULL_TREE, NULL_TREE));
+ return convert_from_reference (build_cxx_call (fn, NULL_TREE));
}
\f
/* Return an lvalue expression whose type is "const std::type_info"
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);
- TREE_TYPE (t) = type_info_ptr_type;
+ t = convert (type_info_ptr_type, t);
}
else
/* Otherwise return the type_info for the static type of the expr. */
{
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;
}
tree var_desc = get_pseudo_ti_desc (type);
d = build_lang_decl (VAR_DECL, name, TINFO_PSEUDO_TYPE (var_desc));
-
+ SET_DECL_ASSEMBLER_NAME (d, name);
+ /* Remember the type it is for. */
+ TREE_TYPE (name) = type;
+ DECL_TINFO_P (d) = 1;
DECL_ARTIFICIAL (d) = 1;
TREE_READONLY (d) = 1;
TREE_STATIC (d) = 1;
+ /* Mark the variable as undefined -- but remember that we can
+ define it later if we need to do so. */
DECL_EXTERNAL (d) = 1;
- DECL_COMDAT (d) = 1;
- TREE_PUBLIC (d) = 1;
- SET_DECL_ASSEMBLER_NAME (d, name);
-
- pushdecl_top_level_and_finish (d, NULL_TREE);
-
+ DECL_NOT_REALLY_EXTERN (d) = 1;
if (CLASS_TYPE_P (type))
CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type)) = d;
-
- /* Remember the type it is for. */
- TREE_TYPE (name) = type;
+ set_linkage_according_to_type (type, d);
+ 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;
}
}
push_nested_namespace (ns);
tinfo_ptr = xref_tag (class_type,
get_identifier ("__class_type_info"),
- /*attributes=*/NULL_TREE,
true, false);
tinfo_ptr = build_pointer_type
pop_nested_namespace (ns);
dynamic_cast_node = dcast_fn;
}
- result = build_cxx_call (dcast_fn, elems, elems);
+ result = build_cxx_call (dcast_fn, elems);
if (tc == REFERENCE_TYPE)
{
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;
}
return !COMPLETE_OR_VOID_TYPE_P (type);
}
+/* Returns true if TYPE involves an incomplete class type; in that
+ case, typeinfo variables for TYPE should be emitted with internal
+ linkage. */
+
+static bool
+involves_incomplete_p (tree type)
+{
+ switch (TREE_CODE (type))
+ {
+ case POINTER_TYPE:
+ return target_incomplete_p (TREE_TYPE (type));
+
+ case OFFSET_TYPE:
+ ptrmem:
+ return
+ (target_incomplete_p (TYPE_PTRMEM_POINTED_TO_TYPE (type))
+ || !COMPLETE_TYPE_P (TYPE_PTRMEM_CLASS_TYPE (type)));
+
+ case RECORD_TYPE:
+ if (TYPE_PTRMEMFUNC_P (type))
+ goto ptrmem;
+ /* Fall through. */
+ case UNION_TYPE:
+ if (!COMPLETE_TYPE_P (type))
+ return true;
+
+ default:
+ /* All other types do not involve incomplete class types. */
+ return false;
+ }
+}
+
/* Return a CONSTRUCTOR for the common part of the type_info objects. This
is the vtable pointer and NTBS name. The NTBS name is emitted as a
comdat const char array, so it becomes a unique key for the type. Generate
NULL_TREE);
tree name_string = tinfo_name (target);
+ /* Determine the name of the variable -- and remember with which
+ type it is associated. */
name_name = mangle_typeinfo_string_for_type (target);
+ TREE_TYPE (name_name) = target;
+
name_decl = build_lang_decl (VAR_DECL, name_name, name_type);
-
+ SET_DECL_ASSEMBLER_NAME (name_decl, name_name);
DECL_ARTIFICIAL (name_decl) = 1;
TREE_READONLY (name_decl) = 1;
TREE_STATIC (name_decl) = 1;
DECL_EXTERNAL (name_decl) = 0;
- TREE_PUBLIC (name_decl) = 1;
- comdat_linkage (name_decl);
- /* External name of the string containing the type's name has a
- special name. */
- SET_DECL_ASSEMBLER_NAME (name_decl,
- mangle_typeinfo_string_for_type (target));
+ DECL_TINFO_P (name_decl) = 1;
+ if (involves_incomplete_p (target))
+ {
+ TREE_PUBLIC (name_decl) = 0;
+ DECL_INTERFACE_KNOWN (name_decl) = 1;
+ }
+ else
+ set_linkage_according_to_type (target, name_decl);
+ import_export_decl (name_decl);
DECL_INITIAL (name_decl) = name_string;
mark_used (name_decl);
pushdecl_top_level_and_finish (name_decl, name_string);
push_nested_namespace (abi_node);
real_type = xref_tag (class_type, TINFO_REAL_NAME (desc),
- /*attributes=*/NULL_TREE, true, false);
+ true, false);
pop_nested_namespace (abi_node);
if (!COMPLETE_TYPE_P (real_type))
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),
TYPE_SIZE_UNIT (vtable_entry_type)));
- TREE_CONSTANT (vtable_ptr) = 1;
TINFO_VTABLE_DECL (desc) = vtable_ptr;
}
init = tree_cons (NULL_TREE, decay_conversion (name_decl), init);
init = build_constructor (NULL_TREE, nreverse (init));
- TREE_HAS_CONSTRUCTOR (init) = TREE_CONSTANT (init) = TREE_STATIC (init) = 1;
+ TREE_CONSTANT (init) = 1;
+ TREE_INVARIANT (init) = 1;
+ TREE_STATIC (init) = 1;
init = tree_cons (NULL_TREE, init, NULL_TREE);
return init;
tree init = tinfo_base_init (desc, target);
init = build_constructor (NULL_TREE, init);
- TREE_HAS_CONSTRUCTOR (init) = TREE_CONSTANT (init) = TREE_STATIC (init) = 1;
+ TREE_CONSTANT (init) = 1;
+ TREE_INVARIANT (init) = 1;
+ TREE_STATIC (init) = 1;
return init;
}
which adds target type and qualifier flags members to the type_info base. */
static tree
-ptr_initializer (tree desc, tree target, bool *non_public_ptr)
+ptr_initializer (tree desc, tree target)
{
tree init = tinfo_base_init (desc, target);
tree to = TREE_TYPE (target);
bool incomplete = target_incomplete_p (to);
if (incomplete)
- {
- flags |= 8;
- *non_public_ptr = true;
- }
- init = tree_cons (NULL_TREE, build_int_2 (flags, 0), init);
+ flags |= 8;
+ 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);
init = build_constructor (NULL_TREE, nreverse (init));
- TREE_HAS_CONSTRUCTOR (init) = TREE_CONSTANT (init) = TREE_STATIC (init) = 1;
+ TREE_CONSTANT (init) = 1;
+ TREE_INVARIANT (init) = 1;
+ TREE_STATIC (init) = 1;
return init;
}
base. */
static tree
-ptm_initializer (tree desc, tree target, bool *non_public_ptr)
+ptm_initializer (tree desc, tree target)
{
tree init = tinfo_base_init (desc, target);
tree to = TYPE_PTRMEM_POINTED_TO_TYPE (target);
bool incomplete = target_incomplete_p (to);
if (incomplete)
- {
- flags |= 0x8;
- *non_public_ptr = true;
- }
+ flags |= 0x8;
if (!COMPLETE_TYPE_P (klass))
- {
- flags |= 0x10;
- *non_public_ptr = true;
- }
- init = tree_cons (NULL_TREE, build_int_2 (flags, 0), init);
+ flags |= 0x10;
+ 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);
init);
init = build_constructor (NULL_TREE, nreverse (init));
- TREE_HAS_CONSTRUCTOR (init) = TREE_CONSTANT (init) = TREE_STATIC (init) = 1;
+ TREE_CONSTANT (init) = 1;
+ TREE_INVARIANT (init) = 1;
+ TREE_STATIC (init) = 1;
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 (TREE_VIA_VIRTUAL (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. */
TREE_CHAIN (init) = trail;
init = build_constructor (NULL_TREE, init);
- TREE_HAS_CONSTRUCTOR (init) = TREE_CONSTANT (init) = TREE_STATIC (init) = 1;
+ TREE_CONSTANT (init) = 1;
+ TREE_INVARIANT (init) = 1;
+ TREE_STATIC (init) = 1;
return init;
}
}
}
-/* Generate the initializer for the type info describing
- 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. */
+/* Generate the initializer for the type info describing TYPE. */
static tree
-get_pseudo_ti_init (tree type, tree var_desc, bool *non_public_p)
+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:
- return ptm_initializer (var_desc, type, non_public_p);
+ return ptm_initializer (var_desc, type);
case POINTER_TYPE:
- return ptr_initializer (var_desc, type, non_public_p);
+ return ptr_initializer (var_desc, type);
case ENUMERAL_TYPE:
return generic_initializer (var_desc, type);
break;
case UNION_TYPE:
case RECORD_TYPE:
if (TYPE_PTRMEMFUNC_P (type))
- return ptm_initializer (var_desc, type, non_public_p);
+ return ptm_initializer (var_desc, type);
else if (var_desc == class_desc_type_node)
- {
- if (!COMPLETE_TYPE_P (type))
- /* Emit a non-public class_type_info. */
- *non_public_p = true;
- return class_initializer (var_desc, type, NULL_TREE);
- }
+ return class_initializer (var_desc, type, NULL_TREE);
else if (var_desc == si_class_desc_type_node)
{
- tree base_binfos = BINFO_BASETYPES (TYPE_BINFO (type));
- tree base_binfo = TREE_VEC_ELT (base_binfos, 0);
+ tree base_binfo = BINFO_BASE_BINFO (TYPE_BINFO (type), 0);
tree tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo));
tree base_inits = tree_cons (NULL_TREE, tinfo, NULL_TREE);
}
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_BASETYPES (binfo);
- tree base_binfos = BINFO_BASETYPES (binfo);
- tree base_accesses = BINFO_BASEACCESSES (binfo);
+ int nbases = BINFO_N_BASE_BINFOS (binfo);
+ VEC (tree) *base_accesses = BINFO_BASE_ACCESSES (binfo);
tree base_inits = NULL_TREE;
int ix;
/* Generate the base information initializer. */
for (ix = nbases; ix--;)
{
- tree base_binfo = TREE_VEC_ELT (base_binfos, ix);
+ tree base_binfo = BINFO_BASE_BINFO (binfo, ix);
tree base_init = NULL_TREE;
int flags = 0;
tree tinfo;
tree offset;
- if (TREE_VEC_ELT (base_accesses, ix) == access_public_node)
+ if (VEC_index (tree, base_accesses, ix) == access_public_node)
flags |= 2;
tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo));
- if (TREE_VIA_VIRTUAL (base_binfo))
+ if (BINFO_VIRTUAL_P (base_binfo))
{
/* We store the vtable offset at which the virtual
base offset can be found. */
else
offset = BINFO_OFFSET (base_binfo);
- /* combine offset and flags into one field */
+ /* 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);
- TREE_HAS_CONSTRUCTOR (base_init) = 1;
base_inits = tree_cons (NULL_TREE, base_init, base_inits);
}
base_inits = build_constructor (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);
+ 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);
}
cxx_incomplete_type_error (NULL_TREE, type);
return class_desc_type_node;
}
- else if (!CLASSTYPE_N_BASECLASSES (type))
+ else if (!BINFO_N_BASE_BINFOS (TYPE_BINFO (type)))
return class_desc_type_node;
else
{
tree binfo = TYPE_BINFO (type);
- tree base_binfos = BINFO_BASETYPES (binfo);
- tree base_accesses = BINFO_BASEACCESSES (binfo);
- tree base_binfo = TREE_VEC_ELT (base_binfos, 0);
- int num_bases = TREE_VEC_LENGTH (base_binfos);
+ VEC (tree) *base_accesses = BINFO_BASE_ACCESSES (binfo);
+ tree base_binfo = BINFO_BASE_BINFO (binfo, 0);
+ int num_bases = BINFO_N_BASE_BINFOS (binfo);
if (num_bases == 1
- && TREE_VEC_ELT (base_accesses, 0) == access_public_node
- && !TREE_VIA_VIRTUAL (base_binfo)
+ && VEC_index (tree, base_accesses, 0) == access_public_node
+ && !BINFO_VIRTUAL_P (base_binfo)
&& integer_zerop (BINFO_OFFSET (base_binfo)))
/* single non-virtual public. */
return si_class_desc_type_node;
}
/* Make sure the required builtin types exist for generating the type_info
- varable definitions. */
+ variable definitions. */
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);
push_nested_namespace (abi_node);
bltn_type = xref_tag (class_type,
get_identifier ("__fundamental_type_info"),
- /*attributes=*/NULL_TREE,
true, false);
pop_nested_namespace (abi_node);
if (!COMPLETE_TYPE_P (bltn_type))
return;
- dtor = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (bltn_type), 1);
+ dtor = CLASSTYPE_DESTRUCTORS (bltn_type);
if (DECL_EXTERNAL (dtor))
return;
doing_runtime = 1;
}
}
-/* Return true, iff T is a type_info variable which has not had a
- definition emitted for it. */
-
-static bool
-unemitted_tinfo_decl_p (tree t)
-{
- if (/* It's a var decl */
- TREE_CODE (t) == VAR_DECL
- /* which has a name */
- && DECL_NAME (t)
- /* whose name points back to itself */
- && IDENTIFIER_GLOBAL_VALUE (DECL_NAME (t)) == t
- /* whose name's type is non-null */
- && TREE_TYPE (DECL_NAME (t))
- /* and whose type is a struct */
- && TREE_CODE (TREE_TYPE (t)) == RECORD_TYPE
- /* with a field */
- && TYPE_FIELDS (TREE_TYPE (t))
- /* which is our pseudo type info */
- && TREE_TYPE (TYPE_FIELDS (TREE_TYPE (t))) == ti_desc_type_node)
- return true;
- return false;
-}
-
/* Finish a type info decl. DECL_PTR is a pointer to an unemitted
tinfo decl. Determine whether it needs emitting, and if so
generate the initializer. */
emit_tinfo_decl (tree decl)
{
tree type = TREE_TYPE (DECL_NAME (decl));
- bool non_public;
int in_library = typeinfo_in_lib_p (type);
tree var_desc, var_init;
- my_friendly_assert (unemitted_tinfo_decl_p (decl), 20030307);
+ gcc_assert (DECL_TINFO_P (decl));
- import_export_tinfo (decl, type, in_library);
- if (DECL_REALLY_EXTERN (decl) || !DECL_NEEDED_P (decl))
- return false;
+ if (in_library)
+ {
+ if (doing_runtime)
+ DECL_EXTERNAL (decl) = 0;
+ else
+ {
+ /* If we're not in the runtime, then DECL (which is already
+ DECL_EXTERNAL) will not be defined here. */
+ DECL_INTERFACE_KNOWN (decl) = 1;
+ return false;
+ }
+ }
+ else if (involves_incomplete_p (type))
+ {
+ if (!decl_needed_p (decl))
+ return false;
+ /* If TYPE involves an incomplete class type, then the typeinfo
+ object will be emitted with internal linkage. There is no
+ way to know whether or not types are incomplete until the end
+ of the compilation, so this determination must be deferred
+ until this point. */
+ TREE_PUBLIC (decl) = 0;
+ DECL_EXTERNAL (decl) = 0;
+ DECL_INTERFACE_KNOWN (decl) = 1;
+ }
- if (!doing_runtime && in_library)
+ import_export_decl (decl);
+ if (DECL_NOT_REALLY_EXTERN (decl) && decl_needed_p (decl))
+ {
+ DECL_EXTERNAL (decl) = 0;
+ var_desc = get_pseudo_ti_desc (type);
+ var_init = get_pseudo_ti_init (type, var_desc);
+ DECL_INITIAL (decl) = var_init;
+ mark_used (decl);
+ cp_finish_decl (decl, var_init, NULL_TREE, 0);
+ return true;
+ }
+ else
return false;
-
- non_public = false;
- var_desc = get_pseudo_ti_desc (type);
- var_init = get_pseudo_ti_init (type, var_desc, &non_public);
-
- DECL_EXTERNAL (decl) = 0;
- TREE_PUBLIC (decl) = !non_public;
- if (non_public)
- DECL_COMDAT (decl) = 0;
-
- DECL_INITIAL (decl) = var_init;
- mark_used (decl);
- cp_finish_decl (decl, var_init, NULL_TREE, 0);
- /* cp_finish_decl will have dealt with linkage. */
-
- /* Say we've dealt with it. */
- TREE_TYPE (DECL_NAME (decl)) = NULL_TREE;
-
- return true;
}