diff options
-rw-r--r-- | gcc/ChangeLog | 32 | ||||
-rw-r--r-- | gcc/Makefile.in | 4 | ||||
-rw-r--r-- | gcc/c-decl.c | 10 | ||||
-rw-r--r-- | gcc/c-lang.c | 6 | ||||
-rw-r--r-- | gcc/c-objc-common.c | 3 | ||||
-rw-r--r-- | gcc/c-tree.h | 6 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/cp-lang.c | 7 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 3 | ||||
-rw-r--r-- | gcc/cp/decl.c | 20 | ||||
-rw-r--r-- | gcc/function.c | 24 | ||||
-rw-r--r-- | gcc/function.h | 7 | ||||
-rw-r--r-- | gcc/langhooks-def.h | 16 | ||||
-rw-r--r-- | gcc/langhooks.c | 10 | ||||
-rw-r--r-- | gcc/langhooks.h | 23 | ||||
-rw-r--r-- | gcc/objc/objc-lang.c | 7 |
16 files changed, 136 insertions, 52 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 004339e..f3556f8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,35 @@ +2002-04-20 Neil Booth <neil@daikokuya.demon.co.uk> + + * Makefile.in: Update. + * decl.c (push_c_function_context, pop_c_function_context, + mark_c_function_context): Rename for consistency. + * c-objc-common.c (c_objc_common_init): Langhooks set elsewhere. + * c-tree.h (push_c_function_context, pop_c_function_context, + mark_c_function_context): Rename for consistency. + * c-lang.c (LANG_HOOKS_FUNCTION_ENTER_NESTED, + LANG_HOOKS_FUNCTION_LEAVE_NESTED, LANG_HOOKS_FUNCTION_MARK): Redefine. + * function.c (init_lang_status, save_lang_status, + restore_lang_status, mark_lang_status, free_lang_status): + Move to langhooks.h. + (push_function_context_to, pop_function_context_from, + free_after_parsing, prepare_function_start, ggc_mark_struct_function): + Update. + * function.h (init_lang_status, save_lang_status, + restore_lang_status, mark_lang_status, free_lang_status): + Move to langhooks.h. + * langhooks-def.h (LANG_HOOKS_FUNCTION_INIT, + LANG_HOOKS_FUNCTION_FREE, LANG_HOOKS_FUNCTION_ENTER_NESTED, + LANG_HOOKS_FUNCTION_LEAVE_NESTED, LANG_HOOKS_FUNCTION_MARK, + LANG_HOOKS_FUNCTION_INITIALIZER): New. + (LANG_HOOKS_INITIALIZER): Update. + (lhd_do_nothing_f): New. + * langhooks.h (struct lang_hooks_for_functions): New. + (struct lang_hooks): New hooks. + * langhooks.c (lhd_do_nothing_f): New. +objc: + * objc-lang.c (LANG_HOOKS_FUNCTION_ENTER_NESTED, + LANG_HOOKS_FUNCTION_LEAVE_NESTED, LANG_HOOKS_FUNCTION_MARK): Redefine. + 2002-04-19 David S. Miller <davem@redhat.com> * config/sparc/linux.h (MD_FALLBACK_FRAME_STATE_FOR): Define. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index bb8e29e..9d88ac6 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1154,9 +1154,9 @@ c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) $(C_TREE_H) \ c-typeck.o : c-typeck.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \ $(TARGET_H) flags.h intl.h output.h $(EXPR_H) $(RTL_H) toplev.h $(TM_P_H) c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \ - langhooks.h langhooks-def.h + langhooks.h langhooks-def.h c-common.h c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) c-lex.h \ - debug.h $(C_TREE_H) \ + debug.h $(C_TREE_H) c-common.h \ c-pragma.h input.h intl.h flags.h toplev.h output.h \ mbchar.h $(CPPLIB_H) $(EXPR_H) $(TM_P_H) c-objc-common.o : c-objc-common.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \ diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 7db66d7..71ece88 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -6712,7 +6712,7 @@ finish_function (nested, can_defer_p) /* Let the error reporting routines know that we're outside a function. For a nested function, this value is used in - pop_c_function_context and then reset via pop_function_context. */ + c_pop_function_context and then reset via pop_function_context. */ current_function_decl = NULL; } } @@ -6887,7 +6887,7 @@ c_expand_body (fndecl, nested_p, can_defer_p) /* Stop pointing to the local nodes about to be freed. But DECL_INITIAL must remain nonzero so we know this was an actual function definition. - For a nested function, this is done in pop_c_function_context. + For a nested function, this is done in c_pop_function_context. If rest_of_compilation set this to 0, leave it 0. */ if (DECL_INITIAL (fndecl) != 0) DECL_INITIAL (fndecl) = error_mark_node; @@ -6998,7 +6998,7 @@ struct c_language_function used during compilation of a C function. */ void -push_c_function_context (f) +c_push_function_context (f) struct function *f; { struct c_language_function *p; @@ -7021,7 +7021,7 @@ push_c_function_context (f) /* Restore the variables used during compilation of a C function. */ void -pop_c_function_context (f) +c_pop_function_context (f) struct function *f; { struct c_language_function *p @@ -7062,7 +7062,7 @@ pop_c_function_context (f) /* Mark the language specific parts of F for GC. */ void -mark_c_function_context (f) +c_mark_function_context (f) struct function *f; { struct c_language_function *p diff --git a/gcc/c-lang.c b/gcc/c-lang.c index ec1f152..f24742d 100644 --- a/gcc/c-lang.c +++ b/gcc/c-lang.c @@ -74,6 +74,12 @@ static void c_post_options PARAMS ((void)); #define LANG_HOOKS_PRINT_IDENTIFIER c_print_identifier #undef LANG_HOOKS_SET_YYDEBUG #define LANG_HOOKS_SET_YYDEBUG c_set_yydebug +#undef LANG_HOOKS_FUNCTION_ENTER_NESTED +#define LANG_HOOKS_FUNCTION_ENTER_NESTED c_push_function_context +#undef LANG_HOOKS_FUNCTION_LEAVE_NESTED +#define LANG_HOOKS_FUNCTION_LEAVE_NESTED c_pop_function_context +#undef LANG_HOOKS_FUNCTION_MARK +#define LANG_HOOKS_FUNCTION_MARK c_mark_function_context #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL c_dup_lang_specific_decl diff --git a/gcc/c-objc-common.c b/gcc/c-objc-common.c index 36b5db4..df16be1 100644 --- a/gcc/c-objc-common.c +++ b/gcc/c-objc-common.c @@ -234,9 +234,6 @@ c_objc_common_init (filename) if (filename == NULL) return NULL; - save_lang_status = &push_c_function_context; - restore_lang_status = &pop_c_function_context; - mark_lang_status = &mark_c_function_context; lang_expand_decl_stmt = c_expand_decl_stmt; /* These were not defined in the Objective-C front end, but I'm diff --git a/gcc/c-tree.h b/gcc/c-tree.h index 21f1146..eedaa7a 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -206,9 +206,9 @@ extern tree lookup_name PARAMS ((tree)); extern tree lookup_name_current_level PARAMS ((tree)); extern void parmlist_tags_warning PARAMS ((void)); extern void pending_xref_error PARAMS ((void)); -extern void mark_c_function_context PARAMS ((struct function *)); -extern void push_c_function_context PARAMS ((struct function *)); -extern void pop_c_function_context PARAMS ((struct function *)); +extern void c_mark_function_context PARAMS ((struct function *)); +extern void c_push_function_context PARAMS ((struct function *)); +extern void c_pop_function_context PARAMS ((struct function *)); extern void pop_label_level PARAMS ((void)); extern void push_label_level PARAMS ((void)); extern void push_parm_decl PARAMS ((tree)); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7a139f4..67c67b8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2002-04-20 Neil Booth <neil@daikokuya.demon.co.uk> + + * cp-lang.c (LANG_HOOKS_FUNCTION_INIT, + LANG_HOOKS_FUNCTION_FREE, LANG_HOOKS_FUNCTION_MARK): Redefine. + * cp-tree.h (cxx_push_function_context, cxx_pop_function_context, + cxx_mark_function_context): New. + * decl.c (push_cp_function_context, pop_cp_function_context, + mark_cp_function_context): Rename for consistency. + (cxx_init_decl_processing): Don't set old hooks. + 2002-04-19 Neil Booth <neil@daikokuya.demon.co.uk> * call.c (convert_type_from_ellipsis): Rename, update. diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c index d37cd11..0cca267 100644 --- a/gcc/cp/cp-lang.c +++ b/gcc/cp/cp-lang.c @@ -93,6 +93,13 @@ static bool cxx_warn_unused_global_decl PARAMS ((tree)); #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl +#undef LANG_HOOKS_FUNCTION_INIT +#define LANG_HOOKS_FUNCTION_INIT cxx_push_function_context +#undef LANG_HOOKS_FUNCTION_FREE +#define LANG_HOOKS_FUNCTION_FREE cxx_pop_function_context +#undef LANG_HOOKS_FUNCTION_MARK +#define LANG_HOOKS_FUNCTION_MARK cxx_mark_function_context + #undef LANG_HOOKS_TREE_INLINING_WALK_SUBTREES #define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES \ cp_walk_subtrees diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 5b56331..bdc4b4f 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3658,6 +3658,9 @@ extern void cxx_init_decl_processing PARAMS ((void)); extern void cxx_mark_tree PARAMS ((tree)); extern void cxx_insert_default_attributes PARAMS ((tree)); extern bool cxx_mark_addressable PARAMS ((tree)); +extern void cxx_push_function_context PARAMS ((struct function *)); +extern void cxx_pop_function_context PARAMS ((struct function *)); +extern void cxx_mark_function_context PARAMS ((struct function *)); extern int toplevel_bindings_p PARAMS ((void)); extern int namespace_bindings_p PARAMS ((void)); extern void keep_next_level PARAMS ((int)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ec08798..58d93bc 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -128,11 +128,8 @@ static void layout_var_decl PARAMS ((tree)); static void maybe_commonize_var PARAMS ((tree)); static tree check_initializer PARAMS ((tree, tree)); static void make_rtl_for_nonlocal_decl PARAMS ((tree, tree, const char *)); -static void push_cp_function_context PARAMS ((struct function *)); -static void pop_cp_function_context PARAMS ((struct function *)); static void mark_binding_level PARAMS ((void *)); static void mark_named_label_lists PARAMS ((void *, void *)); -static void mark_cp_function_context PARAMS ((struct function *)); static void mark_saved_scope PARAMS ((void *)); static void mark_lang_function PARAMS ((struct cp_language_function *)); static void save_function_data PARAMS ((tree)); @@ -6481,9 +6478,6 @@ cxx_init_decl_processing () initialize_predefined_identifiers (); /* Fill in back-end hooks. */ - init_lang_status = &push_cp_function_context; - free_lang_status = &pop_cp_function_context; - mark_lang_status = &mark_cp_function_context; lang_missing_noreturn_ok_p = &cp_missing_noreturn_ok_p; cp_parse_init (); @@ -14340,7 +14334,7 @@ finish_function (flags) if (! nested) /* Let the error reporting routines know that we're outside a function. For a nested function, this value is used in - pop_cp_function_context and then reset via pop_function_context. */ + cxx_pop_function_context and then reset via pop_function_context. */ current_function_decl = NULL_TREE; return fndecl; @@ -14629,8 +14623,8 @@ revert_static_member_fn (decl) /* Initialize the variables used during compilation of a C++ function. */ -static void -push_cp_function_context (f) +void +cxx_push_function_context (f) struct function *f; { struct cp_language_function *p @@ -14650,8 +14644,8 @@ push_cp_function_context (f) /* Free the language-specific parts of F, now that we've finished compiling the function. */ -static void -pop_cp_function_context (f) +void +cxx_pop_function_context (f) struct function *f; { if (f->language) @@ -14689,8 +14683,8 @@ mark_lang_function (p) /* Mark the language-specific data in F for GC. */ -static void -mark_cp_function_context (f) +void +cxx_mark_function_context (f) struct function *f; { mark_lang_function ((struct cp_language_function *) f->language); diff --git a/gcc/function.c b/gcc/function.c index ab3654a..e22273d 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -133,13 +133,6 @@ void (*free_machine_status) PARAMS ((struct function *)); that will need garbage collection. */ void (*mark_machine_status) PARAMS ((struct function *)); -/* Likewise, but for language-specific data. */ -void (*init_lang_status) PARAMS ((struct function *)); -void (*save_lang_status) PARAMS ((struct function *)); -void (*restore_lang_status) PARAMS ((struct function *)); -void (*mark_lang_status) PARAMS ((struct function *)); -void (*free_lang_status) PARAMS ((struct function *)); - /* The FUNCTION_DECL for an inline function currently being expanded. */ tree inline_function_decl; @@ -328,7 +321,7 @@ find_function_data (decl) /* Save the current context for compilation of a nested function. This is called from language-specific code. The caller should use - the save_lang_status callback to save any language-specific state, + the enter_nested langhook to save any language-specific state, since this function knows only about language-independent variables. */ @@ -357,8 +350,7 @@ push_function_context_to (context) outer_function_chain = p; p->fixup_var_refs_queue = 0; - if (save_lang_status) - (*save_lang_status) (p); + (*lang_hooks.function.enter_nested) (p); cfun = 0; } @@ -387,8 +379,7 @@ pop_function_context_from (context) restore_emit_status (p); - if (restore_lang_status) - (*restore_lang_status) (p); + (*lang_hooks.function.leave_nested) (p); /* Finish doing put_var_into_stack for any of our variables which became addressable during the nested function. If only one entry has to be @@ -441,8 +432,7 @@ free_after_parsing (f) /* f->varasm is used by code generation. */ /* f->eh->eh_return_stub_label is used by code generation. */ - if (free_lang_status) - (*free_lang_status) (f); + (*lang_hooks.function.free) (f); free_stmt_status (f); } @@ -6301,8 +6291,7 @@ prepare_function_start () current_function_outgoing_args_size = 0; - if (init_lang_status) - (*init_lang_status) (cfun); + (*lang_hooks.function.init) (cfun); if (init_machine_status) (*init_machine_status) (cfun); } @@ -8025,8 +8014,7 @@ ggc_mark_struct_function (f) if (mark_machine_status) (*mark_machine_status) (f); - if (mark_lang_status) - (*mark_lang_status) (f); + (*lang_hooks.function.mark) (f); if (f->original_arg_vector) ggc_mark_rtvec ((rtvec) f->original_arg_vector); diff --git a/gcc/function.h b/gcc/function.h index 256364ab..493543d 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -574,13 +574,6 @@ extern void (*free_machine_status) PARAMS ((struct function *)); that will need garbage collection. */ extern void (*mark_machine_status) PARAMS ((struct function *)); -/* Likewise, but for language-specific data. */ -extern void (*init_lang_status) PARAMS ((struct function *)); -extern void (*mark_lang_status) PARAMS ((struct function *)); -extern void (*save_lang_status) PARAMS ((struct function *)); -extern void (*restore_lang_status) PARAMS ((struct function *)); -extern void (*free_lang_status) PARAMS ((struct function *)); - /* Save and restore status information for a nested function. */ extern void restore_emit_status PARAMS ((struct function *)); extern void free_after_parsing PARAMS ((struct function *)); diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index abbe734..c08f753 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -41,6 +41,7 @@ extern HOST_WIDE_INT hook_get_alias_set_0 PARAMS ((tree)); extern void lhd_do_nothing PARAMS ((void)); extern void lhd_do_nothing_t PARAMS ((tree)); +extern void lhd_do_nothing_f PARAMS ((struct function *)); extern int lhd_decode_option PARAMS ((int, char **)); extern HOST_WIDE_INT lhd_get_alias_set PARAMS ((tree)); extern tree lhd_return_tree PARAMS ((tree)); @@ -109,6 +110,12 @@ tree lhd_tree_inlining_convert_parm_for_inlining PARAMS ((tree, tree, tree)); #define LANG_HOOKS_DECL_PRINTABLE_NAME lhd_decl_printable_name #define LANG_HOOKS_SET_YYDEBUG lhd_set_yydebug +#define LANG_HOOKS_FUNCTION_INIT lhd_do_nothing_f +#define LANG_HOOKS_FUNCTION_FREE lhd_do_nothing_f +#define LANG_HOOKS_FUNCTION_ENTER_NESTED lhd_do_nothing_f +#define LANG_HOOKS_FUNCTION_LEAVE_NESTED lhd_do_nothing_f +#define LANG_HOOKS_FUNCTION_MARK lhd_do_nothing_f + /* Tree inlining hooks. */ #define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES lhd_tree_inlining_walk_subtrees #define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \ @@ -146,6 +153,14 @@ tree lhd_tree_inlining_convert_parm_for_inlining PARAMS ((tree, tree, tree)); LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \ } \ +#define LANG_HOOKS_FUNCTION_INITIALIZER { \ + LANG_HOOKS_FUNCTION_INIT, \ + LANG_HOOKS_FUNCTION_FREE, \ + LANG_HOOKS_FUNCTION_ENTER_NESTED, \ + LANG_HOOKS_FUNCTION_LEAVE_NESTED, \ + LANG_HOOKS_FUNCTION_MARK \ +} + /* Tree dump hooks. */ int lhd_tree_dump_dump_tree PARAMS ((void *, tree)); int lhd_tree_dump_type_quals PARAMS ((tree)); @@ -231,6 +246,7 @@ int lhd_tree_dump_type_quals PARAMS ((tree)); LANG_HOOKS_DECL_PRINTABLE_NAME, \ LANG_HOOKS_PRINT_ERROR_FUNCTION, \ LANG_HOOKS_SET_YYDEBUG, \ + LANG_HOOKS_FUNCTION_INITIALIZER, \ LANG_HOOKS_TREE_INLINING_INITIALIZER, \ LANG_HOOKS_TREE_DUMP_INITIALIZER, \ LANG_HOOKS_DECLS, \ diff --git a/gcc/langhooks.c b/gcc/langhooks.c index cc08e46..0bbb5e3 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -39,7 +39,7 @@ lhd_do_nothing () { } -/* Do nothing. */ +/* Do nothing (tree). */ void lhd_do_nothing_t (t) @@ -47,6 +47,14 @@ lhd_do_nothing_t (t) { } +/* Do nothing (function). */ + +void +lhd_do_nothing_f (f) + struct function *f ATTRIBUTE_UNUSED; +{ +} + /* Do nothing (return the tree node passed). */ tree diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 5b128a7..4ec27db 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -57,6 +57,26 @@ struct lang_hooks_for_tree_inlining union tree_node *)); }; +/* Lang hooks for management of language-specific data or status + when entering / leaving functions etc. */ +struct lang_hooks_for_functions +{ + /* Called when entering a function. */ + void (*init) PARAMS ((struct function *)); + + /* Called when leaving a function. */ + void (*free) PARAMS ((struct function *)); + + /* Called when entering a nested function. */ + void (*enter_nested) PARAMS ((struct function *)); + + /* Called when leaving a nested function. */ + void (*leave_nested) PARAMS ((struct function *)); + + /* Lang-specific function data marking for GC. */ + void (*mark) PARAMS ((struct function *)); +}; + /* The following hooks are used by tree-dump.c. */ struct lang_hooks_for_tree_dump @@ -312,6 +332,9 @@ struct lang_hooks warning that the front end does not use such a parser. */ void (*set_yydebug) PARAMS ((int)); + /* Function-related language hooks. */ + struct lang_hooks_for_functions function; + struct lang_hooks_for_tree_inlining tree_inlining; struct lang_hooks_for_tree_dump tree_dump; diff --git a/gcc/objc/objc-lang.c b/gcc/objc/objc-lang.c index fef5196..e5b160a 100644 --- a/gcc/objc/objc-lang.c +++ b/gcc/objc/objc-lang.c @@ -73,6 +73,13 @@ static void objc_post_options PARAMS ((void)); #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL c_warn_unused_global_decl +#undef LANG_HOOKS_FUNCTION_ENTER_NESTED +#define LANG_HOOKS_FUNCTION_ENTER_NESTED c_push_function_context +#undef LANG_HOOKS_FUNCTION_LEAVE_NESTED +#define LANG_HOOKS_FUNCTION_LEAVE_NESTED c_pop_function_context +#undef LANG_HOOKS_FUNCTION_MARK +#define LANG_HOOKS_FUNCTION_MARK c_mark_function_context + /* Inlining hooks same as the C front end. */ #undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN #define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \ |