This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Divorce of return warnings


Hi,
with CFG inlining we want to warn about control reaching without return
statement before inlining so we don't ahve to duplicate the logic in
inliner.  This however breaks some of testcases checking warning about
missing noreturn flag as we don't discover tail recursion.
It seem to make sense to make those warnings happen at different stages
of compilation (in general I don't like warnings depend on optimization)

Bootstrapped/regtested i686-pc-gnu-linux as a part of the CFG inliner
aptch, separate testing in progress, OK if it passes?
Honza

2005-05-13  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.

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:22:26 -0000
*************** 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)
--- 5630,5635 ----
*************** struct tree_opt_pass pass_warn_function_
*** 5741,5743 ****
--- 5733,5766 ----
    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 */
+ };
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:22:26 -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:22:26 -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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]