This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
In the new ABI, constructors and destructors will be handled differently. Rather than an in-charge parameter, there will be distinct entry points for in-charge vs. not-in-charge constructors. This patch is the very beginning of that work, and contains some other minor cleanups as well. -- Mark Mitchell mark@codesourcery.com CodeSourcery, LLC http://www.codesourcery.com 2000-04-08 Mark Mitchell <mark@codesourcery.com> * cp-tree.h (cp_tree_index): Add CPTI_BASE_CTOR_IDENTIFIER, CPTI_BASE_DTOR_IDENTIFIER, and CPTI_DELETING_DTOR_IDENTIFIER. (base_ctor_identifier): New macro. (base_dtor_identifier): Likewise. (deleting_dtor_identifier): Likewise. * decl.c: Don't include obstack.h. (obstack_chunk_alloc): Don't define. (obstack_chunk_free): Likewise. (struct predefined_identifier): New type. (initialize_predefined_identifiers): New function. (init_decl_processing): Use it. (debug_temp_inits): Remove. (start_method): Don't call preserve_data. (hack_incomplete_structures): Update comment. * init.c (init_init_processing): Don't initialize nelts_identifier. (build_offset_rf): Remove dead code. (build_delete): Use CLASSTYPE_N_BASECLASSES. * search.c (init_search_processing): Don't initialize vptr_identifier. Index: cp-tree.h =================================================================== RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.h,v retrieving revision 1.432 diff -c -p -r1.432 cp-tree.h *** cp-tree.h 2000/04/06 16:30:43 1.432 --- cp-tree.h 2000/04/09 00:20:45 *************** enum cp_tree_index *** 560,568 **** CPTI_ACCESS_PRIVATE_VIRTUAL, CPTI_CTOR_IDENTIFIER, CPTI_DELTA2_IDENTIFIER, CPTI_DELTA_IDENTIFIER, - CPTI_DTOR_IDENTIFIER, CPTI_IN_CHARGE_IDENTIFIER, CPTI_INDEX_IDENTIFIER, CPTI_NELTS_IDENTIFIER, --- 560,571 ---- CPTI_ACCESS_PRIVATE_VIRTUAL, CPTI_CTOR_IDENTIFIER, + CPTI_BASE_CTOR_IDENTIFIER, + CPTI_DTOR_IDENTIFIER, + CPTI_BASE_DTOR_IDENTIFIER, + CPTI_DELETING_DTOR_IDENTIFIER, CPTI_DELTA2_IDENTIFIER, CPTI_DELTA_IDENTIFIER, CPTI_IN_CHARGE_IDENTIFIER, CPTI_INDEX_IDENTIFIER, CPTI_NELTS_IDENTIFIER, *************** extern tree cp_global_trees[CPTI_MAX]; *** 652,661 **** /* We cache these tree nodes so as to call get_identifier less frequently. */ #define ctor_identifier cp_global_trees[CPTI_CTOR_IDENTIFIER] #define delta2_identifier cp_global_trees[CPTI_DELTA2_IDENTIFIER] #define delta_identifier cp_global_trees[CPTI_DELTA_IDENTIFIER] - #define dtor_identifier cp_global_trees[CPTI_DTOR_IDENTIFIER] #define in_charge_identifier cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER] #define index_identifier cp_global_trees[CPTI_INDEX_IDENTIFIER] #define nelts_identifier cp_global_trees[CPTI_NELTS_IDENTIFIER] --- 655,675 ---- /* We cache these tree nodes so as to call get_identifier less frequently. */ + /* The name of a constructor that constructors virtual base classes. */ #define ctor_identifier cp_global_trees[CPTI_CTOR_IDENTIFIER] + /* The name of a constructor that does not construct virtual base classes. */ + #define base_ctor_identifier cp_global_trees[CPTI_BASE_CTOR_IDENTIFIER] + /* The name of a destructor that destroys virtual base classes. */ + #define dtor_identifier cp_global_trees[CPTI_DTOR_IDENTIFIER] + /* The name of a destructor that does not destroy virtual base + classes. */ + #define base_dtor_identifier cp_global_trees[CPTI_BASE_DTOR_IDENTIFIER] + /* The name of a destructor that destroys virtual base classes, and + then deletes the entire object. */ + #define deleting_dtor_identifier cp_global_trees[CPTI_DELETING_DTOR_IDENTIFIER] + #define delta2_identifier cp_global_trees[CPTI_DELTA2_IDENTIFIER] #define delta_identifier cp_global_trees[CPTI_DELTA_IDENTIFIER] #define in_charge_identifier cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER] #define index_identifier cp_global_trees[CPTI_INDEX_IDENTIFIER] #define nelts_identifier cp_global_trees[CPTI_NELTS_IDENTIFIER] Index: decl.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v retrieving revision 1.581 diff -c -p -r1.581 decl.c *** decl.c 2000/04/06 16:30:44 1.581 --- decl.c 2000/04/09 00:20:55 *************** Boston, MA 02111-1307, USA. */ *** 37,43 **** #include "decl.h" #include "lex.h" #include <signal.h> - #include "obstack.h" #include "defaults.h" #include "output.h" #include "except.h" --- 37,42 ---- *************** Boston, MA 02111-1307, USA. */ *** 46,56 **** #include "defaults.h" #include "ggc.h" - #define obstack_chunk_alloc xmalloc - #define obstack_chunk_free free - - extern struct obstack permanent_obstack; - extern int current_class_depth; extern tree static_ctors, static_dtors; --- 45,50 ---- *************** record_unknown_type (type, name) *** 6041,6046 **** --- 6035,6084 ---- TYPE_MODE (type) = TYPE_MODE (void_type_node); } + /* An string for which we should create an IDENTIFIER_NODE at + startup. */ + + typedef struct predefined_identifier + { + /* The name of the identifier. */ + const char *name; + /* The place where the IDENTIFIER_NODE should be stored. */ + tree *node; + } predefined_identifier; + + /* Create all the predefined identifiers. */ + + static void + initialize_predefined_identifiers () + { + struct predefined_identifier *pid; + + /* A table of identifiers to create at startup. */ + static predefined_identifier predefined_identifiers[] = { + { "C++", &lang_name_cplusplus }, + { "C", &lang_name_c }, + { "Java", &lang_name_java }, + { CTOR_NAME, &ctor_identifier }, + { "__base_ctor", &base_ctor_identifier }, + { DTOR_NAME, &dtor_identifier }, + { "__base_dtor", &base_dtor_identifier }, + { "__deleting_dtor", &deleting_dtor_identifier }, + { VTABLE_DELTA2_NAME, &delta2_identifier }, + { VTABLE_DELTA_NAME, &delta_identifier }, + { IN_CHARGE_NAME, &in_charge_identifier }, + { VTABLE_INDEX_NAME, &index_identifier }, + { "nelts", &nelts_identifier }, + { THIS_NAME, &this_identifier }, + { VTABLE_PFN_NAME, &pfn_identifier }, + { "__pfn_or_delta2", &pfn_or_delta2_identifier }, + { "_vptr", &vptr_identifier }, + { NULL, NULL } + }; + + for (pid = predefined_identifiers; pid->name; ++pid) + *pid->node = get_identifier (pid->name); + } + /* Create the predefined scalar types of C, and some nodes representing standard constants (0, 1, (void *)0). Initialize the global binding level. *************** init_decl_processing () *** 6058,6067 **** if (flag_new_abi && !flag_vtable_thunks) fatal ("the new ABI requires vtable thunks"); ! /* Have to make these distinct before we try using them. */ ! lang_name_cplusplus = get_identifier ("C++"); ! lang_name_c = get_identifier ("C"); ! lang_name_java = get_identifier ("Java"); /* Let the back-end now how to save and restore language-specific per-function globals. */ --- 6096,6103 ---- if (flag_new_abi && !flag_vtable_thunks) fatal ("the new ABI requires vtable thunks"); ! /* Create all the identifiers we need. */ ! initialize_predefined_identifiers (); /* Let the back-end now how to save and restore language-specific per-function globals. */ *************** init_decl_processing () *** 6133,6148 **** NAMESPACE_LEVEL (global_namespace) = global_binding_level; declare_namespace_level (); - this_identifier = get_identifier (THIS_NAME); - in_charge_identifier = get_identifier (IN_CHARGE_NAME); - ctor_identifier = get_identifier (CTOR_NAME); - dtor_identifier = get_identifier (DTOR_NAME); - pfn_identifier = get_identifier (VTABLE_PFN_NAME); - index_identifier = get_identifier (VTABLE_INDEX_NAME); - delta_identifier = get_identifier (VTABLE_DELTA_NAME); - delta2_identifier = get_identifier (VTABLE_DELTA2_NAME); - pfn_or_delta2_identifier = get_identifier ("__pfn_or_delta2"); - /* Define `int' and `char' first so that dbx will output them first. */ record_builtin_type (RID_INT, NULL_PTR, integer_type_node); record_builtin_type (RID_CHAR, "char", char_type_node); --- 6169,6174 ---- *************** groktypename (typename) *** 6895,6904 **** do go through here. Structure field declarations are done by grokfield and not through here. */ - /* Set this to zero to debug not using the temporary obstack - to parse initializers. */ - int debug_temp_inits = 1; - tree start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) tree declarator, declspecs; --- 6921,6926 ---- *************** start_method (declspecs, declarator, att *** 14308,14319 **** if (processing_template_decl && !DECL_TEMPLATE_SPECIALIZATION (fndecl)) fndecl = push_template_decl (fndecl); - /* We read in the parameters on the maybepermanent_obstack, - but we won't be getting back to them until after we - may have clobbered them. So the call to preserve_data - will keep them safe. */ - preserve_data (); - if (! DECL_FRIEND_P (fndecl)) { if (TREE_CHAIN (fndecl)) --- 14330,14335 ---- *************** hack_incomplete_structures (type) *** 14477,14486 **** } /* If DECL is of a type which needs a cleanup, build that cleanup here. ! See build_delete for information about AUTO_DELETE. ! ! Don't build these on the momentary obstack; they must live ! the life of the binding contour. */ static tree maybe_build_cleanup_1 (decl, auto_delete) --- 14493,14499 ---- } /* If DECL is of a type which needs a cleanup, build that cleanup here. ! See build_delete for information about AUTO_DELETE. */ static tree maybe_build_cleanup_1 (decl, auto_delete) Index: init.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/cp/init.c,v retrieving revision 1.179 diff -c -p -r1.179 init.c *** init.c 2000/04/04 18:13:20 1.179 --- init.c 2000/04/09 00:20:57 *************** void init_init_processing () *** 66,72 **** /* Define the structure that holds header information for arrays allocated via operator new. */ BI_header_type = make_aggr_type (RECORD_TYPE); - nelts_identifier = get_identifier ("nelts"); fields[0] = build_lang_decl (FIELD_DECL, nelts_identifier, sizetype); /* Use the biggest alignment supported by the target to prevent operator --- 66,71 ---- *************** build_offset_ref (type, name) *** 1595,1606 **** type, TREE_OPERAND (name, 0)); name = dtor_identifier; } - #if 0 - /* I think this is wrong, but the draft is unclear. --jason 6/15/98 */ - else if (name == constructor_name_full (type) - || name == constructor_name (type)) - name = ctor_identifier; - #endif if (!COMPLETE_TYPE_P (complete_type (type)) && !TYPE_BEING_DEFINED (type)) --- 1594,1599 ---- *************** build_delete (type, addr, auto_delete, f *** 3184,3190 **** { /* We only get here from finish_function for a destructor. */ tree binfos = BINFO_BASETYPES (TYPE_BINFO (type)); ! int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0; tree base_binfo = n_baseclasses > 0 ? TREE_VEC_ELT (binfos, 0) : NULL_TREE; tree exprstmt = NULL_TREE; tree parent_auto_delete = auto_delete; --- 3177,3183 ---- { /* We only get here from finish_function for a destructor. */ tree binfos = BINFO_BASETYPES (TYPE_BINFO (type)); ! int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (type); tree base_binfo = n_baseclasses > 0 ? TREE_VEC_ELT (binfos, 0) : NULL_TREE; tree exprstmt = NULL_TREE; tree parent_auto_delete = auto_delete; Index: search.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/cp/search.c,v retrieving revision 1.170 diff -c -p -r1.170 search.c *** search.c 2000/04/04 20:46:23 1.170 --- search.c 2000/04/09 00:20:59 *************** void *** 3393,3399 **** init_search_processing () { gcc_obstack_init (&search_obstack); - vptr_identifier = get_identifier ("_vptr"); } void --- 3393,3398 ----
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |