tree-cfg.c (execute_warn_function_return): Break out noreturn warning too..

* tree-cfg.c (execute_warn_function_return): Break out noreturn
	warning too..
	(execute_warn_function_noreturn): ... here.
	(pass_warn_function_noreturn): New pass.
	* tree-pass.h (pass_warn_function_noreturn): Declare
	* tree-optimize.c (init_tree_optimization_passes): Move return
	warnings early and add noreturn warnings at place of previous
	return warnings.

From-SVN: r99696
This commit is contained in:
Jan Hubicka 2005-05-14 16:24:49 +02:00 committed by Jan Hubicka
parent 7af893cb9f
commit aa313ed486
6 changed files with 50 additions and 10 deletions

View File

@ -1,3 +1,14 @@
2005-05-14 Jan Hubicka <jh@suse.cz>
* tree-cfg.c (execute_warn_function_return): Break out noreturn
warning too..
(execute_warn_function_noreturn): ... here.
(pass_warn_function_noreturn): New pass.
* tree-pass.h (pass_warn_function_noreturn): Declare
* tree-optimize.c (init_tree_optimization_passes): Move return
warnings early and add noreturn warnings at place of previous
return warnings.
2005-05-14 Kazu Hirata <kazu@cs.umass.edu>
* tree-ssa-live.c (tpa_init, tpa_delete, tpa_compact,

View File

@ -1,3 +1,7 @@
2005-05-14 Jan Hubicka <jh@suse.cz>
* gcc.dg/noreturn-7.c: Allow control reaches warning.
2005-05-14 Richard Guenther <rguenth@gcc.gnu.org>
* g++.dg/tree-ssa/tmmti-2.C: New testcase.

View File

@ -39,4 +39,4 @@ int k()
if (++z > 10)
_exit(0);
k();
}
} /* { dg-warning "control reaches" } */

View File

@ -5630,14 +5630,6 @@ execute_warn_function_return (void)
edge e;
edge_iterator ei;
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))
warning (0, "%Jfunction might be possible candidate for "
"attribute %<noreturn%>",
cfun->decl);
/* If we have a path to EXIT, then we do return. */
if (TREE_THIS_VOLATILE (cfun->decl)
&& EDGE_COUNT (EXIT_BLOCK_PTR->preds) > 0)
@ -5741,3 +5733,34 @@ struct tree_opt_pass pass_warn_function_return =
0, /* todo_flags_finish */
0 /* letter */
};
/* Emit noreturn warnings. */
static void
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))
warning (0, "%Jfunction might be possible candidate for "
"attribute %<noreturn%>",
cfun->decl);
}
struct tree_opt_pass pass_warn_function_noreturn =
{
NULL, /* name */
NULL, /* gate */
execute_warn_function_noreturn, /* execute */
NULL, /* sub */
NULL, /* next */
0, /* static_pass_number */
0, /* tv_id */
PROP_cfg, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
0, /* todo_flags_finish */
0 /* letter */
};

View File

@ -327,10 +327,11 @@ init_tree_optimization_passes (void)
NEXT_PASS (pass_lower_eh);
NEXT_PASS (pass_build_cfg);
NEXT_PASS (pass_pre_expand);
NEXT_PASS (pass_warn_function_return);
NEXT_PASS (pass_tree_profile);
NEXT_PASS (pass_init_datastructures);
NEXT_PASS (pass_all_optimizations);
NEXT_PASS (pass_warn_function_return);
NEXT_PASS (pass_warn_function_noreturn);
NEXT_PASS (pass_mudflap_2);
NEXT_PASS (pass_free_datastructures);
NEXT_PASS (pass_expand);

View File

@ -197,6 +197,7 @@ extern struct tree_opt_pass pass_stdarg;
extern struct tree_opt_pass pass_early_warn_uninitialized;
extern struct tree_opt_pass pass_late_warn_uninitialized;
extern struct tree_opt_pass pass_warn_function_return;
extern struct tree_opt_pass pass_warn_function_noreturn;
extern struct tree_opt_pass pass_phiopt;
extern struct tree_opt_pass pass_forwprop;
extern struct tree_opt_pass pass_redundant_phi;