-
-/* 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. */
-#define TINFO_PSEUDO_TYPE(NODE) TREE_TYPE (NODE)
-/* The VAR_DECL of the vtable for the type_info derived class. */
-#define TINFO_VTABLE_DECL(NODE) TREE_VALUE (NODE)
-
-extern struct obstack permanent_obstack;
-
-static tree build_headof_sub PARAMS((tree));
-static tree build_headof PARAMS((tree));
-static tree ifnonnull PARAMS((tree, tree));
-static tree tinfo_name PARAMS((tree));
-static tree get_base_offset PARAMS((tree, tree));
-static tree build_dynamic_cast_1 PARAMS((tree, tree));
-static tree throw_bad_cast PARAMS((void));
-static tree throw_bad_typeid PARAMS((void));
-static tree get_tinfo_decl_dynamic PARAMS((tree));
-static tree tinfo_from_decl PARAMS((tree));
-static int qualifier_flags PARAMS((tree));
-static int target_incomplete_p PARAMS((tree));
-static tree tinfo_base_init PARAMS((tree, tree));
-static tree generic_initializer PARAMS((tree, tree));
-static tree ptr_initializer PARAMS((tree, tree, int *));
-static tree ptm_initializer PARAMS((tree, tree, int *));
-static tree dfs_class_hint_mark PARAMS ((tree, void *));
-static tree dfs_class_hint_unmark PARAMS ((tree, void *));
-static int class_hint_flags PARAMS((tree));
-static tree class_initializer PARAMS((tree, tree, tree));
-static tree synthesize_tinfo_var PARAMS((tree, tree));
-static tree create_real_tinfo_var PARAMS((tree, tree, tree, tree, int));
-static tree create_pseudo_type_info PARAMS((const char *, int, ...));
-static tree get_vmi_pseudo_type_info PARAMS((int));
-static void create_tinfo_types PARAMS((void));
-static int typeinfo_in_lib_p PARAMS((tree));
+#include "convert.h"
+#include "target.h"
+#include "c-pragma.h"
+
+/* C++ returns type information to the user in struct type_info
+ objects. We also use type information to implement dynamic_cast and
+ exception handlers. Type information for a particular type is
+ indicated with an ABI defined structure derived from type_info.
+ This would all be very straight forward, but for the fact that the
+ runtime library provides the definitions of the type_info structure
+ and the ABI defined derived classes. We cannot build declarations
+ of them directly in the compiler, but we need to layout objects of
+ their type. Somewhere we have to lie.
+
+ We define layout compatible POD-structs with compiler-defined names
+ and generate the appropriate initializations for them (complete
+ with explicit mention of their vtable). When we have to provide a
+ type_info to the user we reinterpret_cast the internal compiler
+ type to type_info. A well formed program can only explicitly refer
+ to the type_infos of complete types (& cv void). However, we chain
+ pointer type_infos to the pointed-to-type, and that can be
+ incomplete. We only need the addresses of such incomplete
+ type_info objects for static initialization.
+
+ The type information VAR_DECL of a type is held on the
+ IDENTIFIER_GLOBAL_VALUE of the type's mangled name. That VAR_DECL
+ will be the internal type. It will usually have the correct
+ internal type reflecting the kind of type it represents (pointer,
+ array, function, class, inherited class, etc). When the type it
+ represents is incomplete, it will have the internal type
+ corresponding to type_info. That will only happen at the end of
+ translation, when we are emitting the type info objects. */
+
+/* Auxiliary data we hold for each type_info derived object we need. */
+typedef struct GTY (()) tinfo_s {
+ tree type; /* The RECORD_TYPE for this type_info object */
+
+ tree vtable; /* The VAR_DECL of the vtable. Only filled at end of
+ translation. */
+
+ tree name; /* IDENTIFIER_NODE for the ABI specified name of
+ the type_info derived type. */
+} tinfo_s;
+
+DEF_VEC_O(tinfo_s);
+DEF_VEC_ALLOC_O(tinfo_s,gc);
+
+typedef enum tinfo_kind
+{
+ TK_TYPE_INFO_TYPE, /* abi::__type_info_pseudo */
+ TK_BASE_TYPE, /* abi::__base_class_type_info */
+ TK_BUILTIN_TYPE, /* abi::__fundamental_type_info */
+ TK_ARRAY_TYPE, /* abi::__array_type_info */
+ TK_FUNCTION_TYPE, /* abi::__function_type_info */
+ TK_ENUMERAL_TYPE, /* abi::__enum_type_info */
+ TK_POINTER_TYPE, /* abi::__pointer_type_info */
+ TK_POINTER_MEMBER_TYPE, /* abi::__pointer_to_member_type_info */
+ TK_CLASS_TYPE, /* abi::__class_type_info */
+ TK_SI_CLASS_TYPE, /* abi::__si_class_type_info */
+ TK_FIXED /* end of fixed descriptors. */
+ /* ... abi::__vmi_type_info<I> */
+} tinfo_kind;
+
+/* A vector of all tinfo decls that haven't yet been emitted. */
+VEC(tree,gc) *unemitted_tinfo_decls;
+
+/* A vector of all type_info derived types we need. The first few are
+ fixed and created early. The remainder are for multiple inheritance
+ and are generated as needed. */
+static GTY (()) VEC(tinfo_s,gc) *tinfo_descs;
+
+static tree ifnonnull (tree, tree);
+static tree tinfo_name (tree, bool);
+static tree build_dynamic_cast_1 (tree, tree, tsubst_flags_t);
+static tree throw_bad_cast (void);
+static tree throw_bad_typeid (void);
+static tree get_tinfo_decl_dynamic (tree);
+static tree get_tinfo_ptr (tree);
+static bool typeid_ok_p (void);
+static int qualifier_flags (tree);
+static bool target_incomplete_p (tree);
+static tree tinfo_base_init (tinfo_s *, tree);
+static tree generic_initializer (tinfo_s *, tree);
+static tree ptr_initializer (tinfo_s *, tree);
+static tree ptm_initializer (tinfo_s *, tree);
+static tree class_initializer (tinfo_s *, tree, tree);
+static void create_pseudo_type_info (int, const char *, ...);
+static tree get_pseudo_ti_init (tree, unsigned);
+static unsigned get_pseudo_ti_index (tree);
+static void create_tinfo_types (void);
+static bool typeinfo_in_lib_p (tree);