Commit e8924938 by Paolo Bonzini Committed by Paolo Bonzini

function.c (free_after_parsing): Replace with cxx_push_function_context from C++ front-end.

2008-04-03  Paolo Bonzini  <bonzini@gnu.org>

	* 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  <bonzini@gnu.org>

	* 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
parent 05008a0c
2008-04-04 Paolo Bonzini <bonzini@gnu.org>
* 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 <jakub@redhat.com> 2008-04-04 Jakub Jelinek <jakub@redhat.com>
PR c/35440 PR c/35440
......
...@@ -63,8 +63,8 @@ extern void c_initialize_diagnostics (diagnostic_context *); ...@@ -63,8 +63,8 @@ extern void c_initialize_diagnostics (diagnostic_context *);
#define LANG_HOOKS_PRINT_IDENTIFIER c_print_identifier #define LANG_HOOKS_PRINT_IDENTIFIER c_print_identifier
#undef LANG_HOOKS_TYPES_COMPATIBLE_P #undef LANG_HOOKS_TYPES_COMPATIBLE_P
#define LANG_HOOKS_TYPES_COMPATIBLE_P c_types_compatible_p #define LANG_HOOKS_TYPES_COMPATIBLE_P c_types_compatible_p
#undef LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P #undef LANG_HOOKS_MISSING_NORETURN_OK_P
#define LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P c_missing_noreturn_ok_p #define LANG_HOOKS_MISSING_NORETURN_OK_P c_missing_noreturn_ok_p
#undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL c_dup_lang_specific_decl #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL c_dup_lang_specific_decl
#undef LANG_HOOKS_BUILTIN_FUNCTION #undef LANG_HOOKS_BUILTIN_FUNCTION
......
2008-04-04 Paolo Bonzini <bonzini@gnu.org>
* 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 <jakub@redhat.com> 2008-04-03 Jakub Jelinek <jakub@redhat.com>
PR c++/35741 PR c++/35741
......
...@@ -88,13 +88,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, ...@@ -88,13 +88,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t,
#define LANG_HOOKS_BUILTIN_FUNCTION cxx_builtin_function #define LANG_HOOKS_BUILTIN_FUNCTION cxx_builtin_function
#undef LANG_HOOKS_TYPE_HASH_EQ #undef LANG_HOOKS_TYPE_HASH_EQ
#define LANG_HOOKS_TYPE_HASH_EQ cxx_type_hash_eq #define LANG_HOOKS_TYPE_HASH_EQ cxx_type_hash_eq
#undef LANG_HOOKS_MISSING_NORETURN_OK_P
#undef LANG_HOOKS_FUNCTION_INIT #define LANG_HOOKS_MISSING_NORETURN_OK_P cp_missing_noreturn_ok_p
#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
/* Attribute hooks. */ /* Attribute hooks. */
#undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE
......
...@@ -4183,8 +4183,6 @@ extern void cxx_init_decl_processing (void); ...@@ -4183,8 +4183,6 @@ extern void cxx_init_decl_processing (void);
enum cp_tree_node_structure_enum cp_tree_node_structure enum cp_tree_node_structure_enum cp_tree_node_structure
(union lang_tree_node *); (union lang_tree_node *);
extern bool cxx_mark_addressable (tree); 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 maybe_push_cleanup_level (tree);
extern void finish_scope (void); extern void finish_scope (void);
extern void push_switch (tree); extern void push_switch (tree);
......
...@@ -11258,6 +11258,11 @@ start_preparsed_function (tree decl1, tree attrs, int flags) ...@@ -11258,6 +11258,11 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
FIXME factor out the non-RTL stuff. */ FIXME factor out the non-RTL stuff. */
bl = current_binding_level; bl = current_binding_level;
allocate_struct_function (decl1, processing_template_decl); 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; current_binding_level = bl;
/* Even though we're inside a function body, we still don't want to /* Even though we're inside a function body, we still don't want to
...@@ -12269,47 +12274,6 @@ revert_static_member_fn (tree decl) ...@@ -12269,47 +12274,6 @@ revert_static_member_fn (tree decl)
DECL_STATIC_FUNCTION_P (decl) = 1; 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 /* Return which tree structure is used by T, or TS_CP_GENERIC if T is
one of the language-independent trees. */ one of the language-independent trees. */
......
...@@ -381,9 +381,7 @@ add_stmt (tree t) ...@@ -381,9 +381,7 @@ add_stmt (tree t)
return t; return t;
} }
/* Returns the stmt_tree (if any) to which statements are currently /* Returns the stmt_tree to which statements are currently being added. */
being added. If there is no active statement-tree, NULL is
returned. */
stmt_tree stmt_tree
current_stmt_tree (void) current_stmt_tree (void)
......
...@@ -271,12 +271,7 @@ pop_function_context (void) ...@@ -271,12 +271,7 @@ pop_function_context (void)
void void
free_after_parsing (struct function *f) free_after_parsing (struct function *f)
{ {
/* f->expr->forced_labels is used by code generation. */ f->language = 0;
/* 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);
} }
/* Clear out all parts of the state in F that can safely be discarded /* 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) ...@@ -3861,7 +3856,6 @@ allocate_struct_function (tree fndecl, bool abstract_p)
init_eh_for_function (); init_eh_for_function ();
lang_hooks.function.init (cfun);
if (init_machine_status) if (init_machine_status)
cfun->machine = (*init_machine_status) (); cfun->machine = (*init_machine_status) ();
......
...@@ -90,6 +90,7 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *, ...@@ -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_HANDLE_OPTION hook_int_size_t_constcharptr_int_0
#define LANG_HOOKS_MISSING_ARGUMENT hook_bool_constcharptr_size_t_false #define LANG_HOOKS_MISSING_ARGUMENT hook_bool_constcharptr_size_t_false
#define LANG_HOOKS_POST_OPTIONS lhd_post_options #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_GET_ALIAS_SET lhd_get_alias_set
#define LANG_HOOKS_EXPAND_EXPR lhd_expand_expr #define LANG_HOOKS_EXPAND_EXPR lhd_expand_expr
#define LANG_HOOKS_EXPAND_DECL lhd_expand_decl #define LANG_HOOKS_EXPAND_DECL lhd_expand_decl
...@@ -115,10 +116,6 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *, ...@@ -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_TO_TARGET_CHARSET lhd_to_target_charset
#define LANG_HOOKS_INIT_TS lhd_do_nothing #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. */ /* Attribute hooks. */
#define LANG_HOOKS_ATTRIBUTE_TABLE NULL #define LANG_HOOKS_ATTRIBUTE_TABLE NULL
#define LANG_HOOKS_COMMON_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 *, ...@@ -140,12 +137,6 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS, \ 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. */ /* Hooks for tree gimplification. */
#define LANG_HOOKS_GIMPLIFY_EXPR lhd_gimplify_expr #define LANG_HOOKS_GIMPLIFY_EXPR lhd_gimplify_expr
#define LANG_HOOKS_FOLD_OBJ_TYPE_REF NULL #define LANG_HOOKS_FOLD_OBJ_TYPE_REF NULL
...@@ -242,6 +233,7 @@ extern tree lhd_make_node (enum tree_code); ...@@ -242,6 +233,7 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_INIT, \ LANG_HOOKS_INIT, \
LANG_HOOKS_FINISH, \ LANG_HOOKS_FINISH, \
LANG_HOOKS_PARSE_FILE, \ LANG_HOOKS_PARSE_FILE, \
LANG_HOOKS_MISSING_NORETURN_OK_P, \
LANG_HOOKS_GET_ALIAS_SET, \ LANG_HOOKS_GET_ALIAS_SET, \
LANG_HOOKS_EXPAND_EXPR, \ LANG_HOOKS_EXPAND_EXPR, \
LANG_HOOKS_EXPAND_DECL, \ LANG_HOOKS_EXPAND_DECL, \
...@@ -266,7 +258,6 @@ extern tree lhd_make_node (enum tree_code); ...@@ -266,7 +258,6 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_ATTRIBUTE_TABLE, \ LANG_HOOKS_ATTRIBUTE_TABLE, \
LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, \ LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, \
LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE, \ LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE, \
LANG_HOOKS_FUNCTION_INITIALIZER, \
LANG_HOOKS_TREE_INLINING_INITIALIZER, \ LANG_HOOKS_TREE_INLINING_INITIALIZER, \
LANG_HOOKS_CALLGRAPH_INITIALIZER, \ LANG_HOOKS_CALLGRAPH_INITIALIZER, \
LANG_HOOKS_TREE_DUMP_INITIALIZER, \ LANG_HOOKS_TREE_DUMP_INITIALIZER, \
......
...@@ -54,20 +54,6 @@ struct lang_hooks_for_callgraph ...@@ -54,20 +54,6 @@ struct lang_hooks_for_callgraph
void (*emit_associated_thunks) (tree); 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. */ /* The following hooks are used by tree-dump.c. */
struct lang_hooks_for_tree_dump struct lang_hooks_for_tree_dump
...@@ -283,6 +269,9 @@ struct lang_hooks ...@@ -283,6 +269,9 @@ struct lang_hooks
parsers to dump debugging information during parsing. */ parsers to dump debugging information during parsing. */
void (*parse_file) (int); 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. /* Called to obtain the alias set to be used for an expression or type.
Returns -1 if the language does nothing special for it. */ Returns -1 if the language does nothing special for it. */
alias_set_type (*get_alias_set) (tree); alias_set_type (*get_alias_set) (tree);
...@@ -386,9 +375,6 @@ struct lang_hooks ...@@ -386,9 +375,6 @@ struct lang_hooks
const struct attribute_spec *common_attribute_table; const struct attribute_spec *common_attribute_table;
const struct attribute_spec *format_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_tree_inlining tree_inlining;
struct lang_hooks_for_callgraph callgraph; struct lang_hooks_for_callgraph callgraph;
......
...@@ -7085,7 +7085,7 @@ execute_warn_function_noreturn (void) ...@@ -7085,7 +7085,7 @@ execute_warn_function_noreturn (void)
if (warn_missing_noreturn if (warn_missing_noreturn
&& !TREE_THIS_VOLATILE (cfun->decl) && !TREE_THIS_VOLATILE (cfun->decl)
&& EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0 && 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 " warning (OPT_Wmissing_noreturn, "%Jfunction might be possible candidate "
"for attribute %<noreturn%>", "for attribute %<noreturn%>",
cfun->decl); cfun->decl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment