From: Paolo Bonzini Date: Fri, 4 Apr 2008 14:57:18 +0000 (+0000) Subject: function.c (free_after_parsing): Replace with cxx_push_function_context from C++... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e892493899b225a21746d24221d7dc45fc19fed2;p=gcc.git function.c (free_after_parsing): Replace with cxx_push_function_context from C++ front-end. 2008-04-03 Paolo Bonzini * function.c (free_after_parsing): Replace with cxx_push_function_context from C++ front-end. (allocate_struct_function): Don't call langhook. * langhooks.h (struct lang_hooks_for_functions): Delete. (struct lang_hooks): Add back missing_noreturn_ok_p here, delete member "function". * langhooks-def.h (LANG_HOOKS_MISSING_NORETURN_OK_P): Add. (LANG_HOOKS_FUNCTION_INIT, LANG_HOOKS_FUNCTION_FINAL, LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P, LANG_HOOKS_FUNCTION_INITIALIZER): Delete. (LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_MISSING_NORETURN_OK_P, remove LANG_HOOKS_FUNCTION_INITIALIZER. * tree-cfg.c: Adjust call to missing_noreturn_ok_p langhook. * c-objc-common.h (LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P): Rename to LANG_HOOKS_MISSING_NORETURN_OK_P. cp: 2008-04-03 Paolo Bonzini * decl.c (cxx_push_function_context): Delete. (cxx_pop_function_context): Delete. (start_preparsed_function): Merge cxx_push_function_context (!f->decl code only). * cp-objcp-common.h (LANG_HOOKS_FUNCTION_INIT, LANG_HOOKS_FUNCTION_FINAL): Delete. (LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P): Rename to LANG_HOOKS_MISSING_NORETURN_OK_P. * cp-tree.h (cxx_push_function_context, cxx_pop_function_context): Delete prototype. * semantics.c (current_stmt_tree): Fix comment. From-SVN: r133900 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 84852dbc1dd..fab141fda0b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,22 @@ +2008-04-04 Paolo Bonzini + + * function.c (free_after_parsing): Replace with + cxx_push_function_context from C++ front-end. + (allocate_struct_function): Don't call langhook. + * langhooks.h (struct lang_hooks_for_functions): Delete. + (struct lang_hooks): Add back missing_noreturn_ok_p here, delete + member "function". + * langhooks-def.h (LANG_HOOKS_MISSING_NORETURN_OK_P): Add. + (LANG_HOOKS_FUNCTION_INIT, LANG_HOOKS_FUNCTION_FINAL, + LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P, + LANG_HOOKS_FUNCTION_INITIALIZER): Delete. + (LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_MISSING_NORETURN_OK_P, + remove LANG_HOOKS_FUNCTION_INITIALIZER. + * tree-cfg.c: Adjust call to missing_noreturn_ok_p langhook. + + * c-objc-common.h (LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P): + Rename to LANG_HOOKS_MISSING_NORETURN_OK_P. + 2008-04-04 Jakub Jelinek PR c/35440 diff --git a/gcc/c-objc-common.h b/gcc/c-objc-common.h index 5494ffb3754..c48838ceb99 100644 --- a/gcc/c-objc-common.h +++ b/gcc/c-objc-common.h @@ -63,8 +63,8 @@ extern void c_initialize_diagnostics (diagnostic_context *); #define LANG_HOOKS_PRINT_IDENTIFIER c_print_identifier #undef LANG_HOOKS_TYPES_COMPATIBLE_P #define LANG_HOOKS_TYPES_COMPATIBLE_P c_types_compatible_p -#undef LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P -#define LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P c_missing_noreturn_ok_p +#undef LANG_HOOKS_MISSING_NORETURN_OK_P +#define LANG_HOOKS_MISSING_NORETURN_OK_P c_missing_noreturn_ok_p #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL c_dup_lang_specific_decl #undef LANG_HOOKS_BUILTIN_FUNCTION diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 713b62e6e0a..6702af2a6c7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,17 @@ +2008-04-04 Paolo Bonzini + + * decl.c (cxx_push_function_context): Delete. + (cxx_pop_function_context): Delete. + (start_preparsed_function): Merge cxx_push_function_context (!f->decl + code only). + * cp-objcp-common.h (LANG_HOOKS_FUNCTION_INIT, + LANG_HOOKS_FUNCTION_FINAL): Delete. + (LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P): Rename to + LANG_HOOKS_MISSING_NORETURN_OK_P. + * cp-tree.h (cxx_push_function_context, cxx_pop_function_context): + Delete prototype. + * semantics.c (current_stmt_tree): Fix comment. + 2008-04-03 Jakub Jelinek PR c++/35741 diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index 8fc69879cab..a15b6b47a4f 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -88,13 +88,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, #define LANG_HOOKS_BUILTIN_FUNCTION cxx_builtin_function #undef LANG_HOOKS_TYPE_HASH_EQ #define LANG_HOOKS_TYPE_HASH_EQ cxx_type_hash_eq - -#undef LANG_HOOKS_FUNCTION_INIT -#define LANG_HOOKS_FUNCTION_INIT cxx_push_function_context -#undef LANG_HOOKS_FUNCTION_FINAL -#define LANG_HOOKS_FUNCTION_FINAL cxx_pop_function_context -#undef LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P -#define LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P cp_missing_noreturn_ok_p +#undef LANG_HOOKS_MISSING_NORETURN_OK_P +#define LANG_HOOKS_MISSING_NORETURN_OK_P cp_missing_noreturn_ok_p /* Attribute hooks. */ #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f50b926ce4b..27212c3c85c 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4183,8 +4183,6 @@ extern void cxx_init_decl_processing (void); enum cp_tree_node_structure_enum cp_tree_node_structure (union lang_tree_node *); extern bool cxx_mark_addressable (tree); -extern void cxx_push_function_context (struct function *); -extern void cxx_pop_function_context (struct function *); extern void maybe_push_cleanup_level (tree); extern void finish_scope (void); extern void push_switch (tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 87374967466..15ebf29d61d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11258,6 +11258,11 @@ start_preparsed_function (tree decl1, tree attrs, int flags) FIXME factor out the non-RTL stuff. */ bl = current_binding_level; allocate_struct_function (decl1, processing_template_decl); + + /* Initialize the language data structures. Whenever we start + a new function, we destroy temporaries in the usual way. */ + cfun->language = GGC_CNEW (struct language_function); + current_stmt_tree ()->stmts_are_full_exprs_p = 1; current_binding_level = bl; /* Even though we're inside a function body, we still don't want to @@ -12269,47 +12274,6 @@ revert_static_member_fn (tree decl) DECL_STATIC_FUNCTION_P (decl) = 1; } -/* Initialize the variables used during compilation of a C++ - function. */ - -void -cxx_push_function_context (struct function * f) -{ - struct language_function *p = GGC_CNEW (struct language_function); - f->language = p; - - /* Whenever we start a new function, we destroy temporaries in the - usual way. */ - current_stmt_tree ()->stmts_are_full_exprs_p = 1; - - if (f->decl) - { - tree fn = f->decl; - - if (DECL_SAVED_FUNCTION_DATA (fn)) - { - /* If we already parsed this function, and we're just expanding it - now, restore saved state. */ - *cp_function_chain = *DECL_SAVED_FUNCTION_DATA (fn); - - /* We don't need the saved data anymore. Unless this is an inline - function; we need the named return value info for - declare_return_variable. */ - if (! DECL_INLINE (fn)) - DECL_SAVED_FUNCTION_DATA (fn) = NULL; - } - } -} - -/* Free the language-specific parts of F, now that we've finished - compiling the function. */ - -void -cxx_pop_function_context (struct function * f) -{ - f->language = 0; -} - /* Return which tree structure is used by T, or TS_CP_GENERIC if T is one of the language-independent trees. */ diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 95ebde69a8d..3a36fddab18 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -381,9 +381,7 @@ add_stmt (tree t) return t; } -/* Returns the stmt_tree (if any) to which statements are currently - being added. If there is no active statement-tree, NULL is - returned. */ +/* Returns the stmt_tree to which statements are currently being added. */ stmt_tree current_stmt_tree (void) diff --git a/gcc/function.c b/gcc/function.c index 197c39375e2..240a3e7615b 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -271,12 +271,7 @@ pop_function_context (void) void free_after_parsing (struct function *f) { - /* f->expr->forced_labels is used by code generation. */ - /* f->emit->regno_reg_rtx is used by code generation. */ - /* f->varasm is used by code generation. */ - /* f->eh->eh_return_stub_label is used by code generation. */ - - lang_hooks.function.final (f); + f->language = 0; } /* Clear out all parts of the state in F that can safely be discarded @@ -3861,7 +3856,6 @@ allocate_struct_function (tree fndecl, bool abstract_p) init_eh_for_function (); - lang_hooks.function.init (cfun); if (init_machine_status) cfun->machine = (*init_machine_status) (); diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index 47996a0d75b..a67ba81974b 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -90,6 +90,7 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *, #define LANG_HOOKS_HANDLE_OPTION hook_int_size_t_constcharptr_int_0 #define LANG_HOOKS_MISSING_ARGUMENT hook_bool_constcharptr_size_t_false #define LANG_HOOKS_POST_OPTIONS lhd_post_options +#define LANG_HOOKS_MISSING_NORETURN_OK_P hook_bool_tree_true #define LANG_HOOKS_GET_ALIAS_SET lhd_get_alias_set #define LANG_HOOKS_EXPAND_EXPR lhd_expand_expr #define LANG_HOOKS_EXPAND_DECL lhd_expand_decl @@ -115,10 +116,6 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *, #define LANG_HOOKS_TO_TARGET_CHARSET lhd_to_target_charset #define LANG_HOOKS_INIT_TS lhd_do_nothing -#define LANG_HOOKS_FUNCTION_INIT lhd_do_nothing_f -#define LANG_HOOKS_FUNCTION_FINAL lhd_do_nothing_f -#define LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P hook_bool_tree_true - /* Attribute hooks. */ #define LANG_HOOKS_ATTRIBUTE_TABLE NULL #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE NULL @@ -140,12 +137,6 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *, LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS, \ } -#define LANG_HOOKS_FUNCTION_INITIALIZER { \ - LANG_HOOKS_FUNCTION_INIT, \ - LANG_HOOKS_FUNCTION_FINAL, \ - LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P \ -} - /* Hooks for tree gimplification. */ #define LANG_HOOKS_GIMPLIFY_EXPR lhd_gimplify_expr #define LANG_HOOKS_FOLD_OBJ_TYPE_REF NULL @@ -242,6 +233,7 @@ extern tree lhd_make_node (enum tree_code); LANG_HOOKS_INIT, \ LANG_HOOKS_FINISH, \ LANG_HOOKS_PARSE_FILE, \ + LANG_HOOKS_MISSING_NORETURN_OK_P, \ LANG_HOOKS_GET_ALIAS_SET, \ LANG_HOOKS_EXPAND_EXPR, \ LANG_HOOKS_EXPAND_DECL, \ @@ -266,7 +258,6 @@ extern tree lhd_make_node (enum tree_code); LANG_HOOKS_ATTRIBUTE_TABLE, \ LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, \ LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE, \ - LANG_HOOKS_FUNCTION_INITIALIZER, \ LANG_HOOKS_TREE_INLINING_INITIALIZER, \ LANG_HOOKS_CALLGRAPH_INITIALIZER, \ LANG_HOOKS_TREE_DUMP_INITIALIZER, \ diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 21e794fae80..722c82cb623 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -54,20 +54,6 @@ struct lang_hooks_for_callgraph void (*emit_associated_thunks) (tree); }; -/* 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) (struct function *); - - /* Called when leaving a function. */ - void (*final) (struct function *); - - /* Determines if it's ok for a function to have no noreturn attribute. */ - bool (*missing_noreturn_ok_p) (tree); -}; - /* The following hooks are used by tree-dump.c. */ struct lang_hooks_for_tree_dump @@ -283,6 +269,9 @@ struct lang_hooks parsers to dump debugging information during parsing. */ void (*parse_file) (int); + /* Determines if it's ok for a function to have no noreturn attribute. */ + bool (*missing_noreturn_ok_p) (tree); + /* Called to obtain the alias set to be used for an expression or type. Returns -1 if the language does nothing special for it. */ alias_set_type (*get_alias_set) (tree); @@ -386,9 +375,6 @@ struct lang_hooks const struct attribute_spec *common_attribute_table; const struct attribute_spec *format_attribute_table; - /* Function-related language hooks. */ - struct lang_hooks_for_functions function; - struct lang_hooks_for_tree_inlining tree_inlining; struct lang_hooks_for_callgraph callgraph; diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 70d0404bc0e..cea11b8661c 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -7085,7 +7085,7 @@ execute_warn_function_noreturn (void) if (warn_missing_noreturn && !TREE_THIS_VOLATILE (cfun->decl) && EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0 - && !lang_hooks.function.missing_noreturn_ok_p (cfun->decl)) + && !lang_hooks.missing_noreturn_ok_p (cfun->decl)) warning (OPT_Wmissing_noreturn, "%Jfunction might be possible candidate " "for attribute %", cfun->decl);