This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Divorce of return warnings
>
> > + 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 "
>
> Could we get in the habit of moving the warn_* into warning(OPT_W* as
> we encounter these? Or at least adding the OPT_W* when the warn_*
> test bypasses expensive checks? Please? ;-)
OK, here is updated patch I am testing.
OK?
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.188
diff -c -3 -p -r2.188 tree-cfg.c
*** tree-cfg.c 13 May 2005 13:56:49 -0000 2.188
--- tree-cfg.c 13 May 2005 19:45:01 -0000
*************** Boston, MA 02111-1307, USA. */
*** 45,50 ****
--- 45,51 ----
#include "cfgloop.h"
#include "cfglayout.h"
#include "hashtab.h"
+ #include "options.h"
/* This file contains functions for building the Control Flow Graph (CFG)
for a function tree. */
*************** execute_warn_function_return (void)
*** 5630,5643 ****
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)
--- 5631,5636 ----
*************** struct tree_opt_pass pass_warn_function_
*** 5741,5743 ****
--- 5734,5772 ----
0, /* todo_flags_finish */
0 /* letter */
};
+
+ /* Emit noreturn warnings. */
+
+ static void
+ execute_warn_function_noreturn (void)
+ {
+ if (!TREE_THIS_VOLATILE (cfun->decl)
+ && EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0
+ && !lang_hooks.function.missing_noreturn_ok_p (cfun->decl))
+ warning (OPT_Wmissing_noreturn, "%Jfunction might be possible candidate for "
+ "attribute %<noreturn%>",
+ cfun->decl);
+ }
+
+ static bool
+ gate_warn_function_noreturn (void)
+ {
+ return warn_missing_noreturn;
+ }
+
+ struct tree_opt_pass pass_warn_function_noreturn =
+ {
+ NULL, /* name */
+ gate_warn_function_noreturn, /* 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 */
+ };
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 2.92
diff -c -3 -p -r2.92 tree-optimize.c
*** tree-optimize.c 13 May 2005 13:56:57 -0000 2.92
--- tree-optimize.c 13 May 2005 19:45:01 -0000
*************** init_tree_optimization_passes (void)
*** 327,336 ****
NEXT_PASS (pass_lower_eh);
NEXT_PASS (pass_build_cfg);
NEXT_PASS (pass_pre_expand);
NEXT_PASS (pass_tree_profile);
NEXT_PASS (pass_init_datastructures);
NEXT_PASS (pass_all_optimizations);
! NEXT_PASS (pass_warn_function_return);
NEXT_PASS (pass_mudflap_2);
NEXT_PASS (pass_free_datastructures);
NEXT_PASS (pass_expand);
--- 327,337 ----
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_noreturn);
NEXT_PASS (pass_mudflap_2);
NEXT_PASS (pass_free_datastructures);
NEXT_PASS (pass_expand);
Index: tree-pass.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-pass.h,v
retrieving revision 2.33
diff -c -3 -p -r2.33 tree-pass.h
*** tree-pass.h 21 Apr 2005 13:18:23 -0000 2.33
--- tree-pass.h 13 May 2005 19:45:01 -0000
*************** extern struct tree_opt_pass pass_stdarg;
*** 197,202 ****
--- 197,203 ----
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;