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]

Re: PR c++/36254 wrong "control reaches end of non-void function" warning


2008/10/23 Richard Guenther <richard.guenther@gmail.com>:
> On Thu, Oct 23, 2008 at 2:57 AM, Manuel López-Ibáñez
> <lopezibanez@gmail.com> wrote:
>> Now with patch.
>>
>> 2008/10/23 Manuel López-Ibáñez <lopezibanez@gmail.com>:
>>> This is similar case as my patch for PR 31246: more cases of
>>> compiler-generated code. In fact, there is some overlap between them.
>>>
>>> Bootstrapped and regression tested on x86_64-unknown-linux-gnu with
>>> --enable-languages=all,obj-c++ --enable-decimal-float.
>>>
>>> OK for trunk?
>
> Wherever you just set TREE_NO_WARNING or gimple_set_no_warning
> (and not propagate it) during gimplification looks fishy.
>
> It looks like for both patches it might work to just disable these warnings for
> EH related code?  (The propagation of the no-warning flag during gimplification
> _does_ look correct, though)
>

It turns out that propagating the no_warning flag is enough to fix
this PR. Bootstrapped and regression tested.

OK for trunk?

2008-10-23  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c++/36254
	* gimplify.c (gimplify_expr): Propagate the no_warning flag.
	* gimple-low.c (lower_function_body): Propagate the no_warning
	flag.
testsuite/	
	* g++dg/eh/pr36254.C: New.
Index: gcc/testsuite/g++.dg/eh/pr36254.C
===================================================================
--- gcc/testsuite/g++.dg/eh/pr36254.C	(revision 0)
+++ gcc/testsuite/g++.dg/eh/pr36254.C	(revision 0)
@@ -0,0 +1,10 @@
+extern int i, j, k;
+struct X { X(); ~X(); };
+bool f()
+{
+  X x;
+  if ( i && j )
+    if ( k < 0 ) return true; else return false;
+  else
+    return false;
+}
Index: gcc/gimple-low.c
===================================================================
--- gcc/gimple-low.c	(revision 141322)
+++ gcc/gimple-low.c	(working copy)
@@ -130,10 +130,13 @@ lower_function_body (void)
       && (VEC_empty (return_statements_t, data.return_statements)
 	  || gimple_return_retval (VEC_last (return_statements_t,
 			           data.return_statements)->stmt) != NULL))
     {
       x = gimple_build_return (NULL);
+      /* Propagate the no_warning flag.  */
+      if (!gsi_end_p (i))
+	gimple_set_no_warning (x, gimple_no_warning_p (gsi_stmt (i)));
       gimple_set_location (x, cfun->function_end_locus);
       gimple_set_block (x, DECL_INITIAL (current_function_decl));
       gsi_insert_after (&i, x, GSI_CONTINUE_LINKING);
     }
 
Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c	(revision 141322)
+++ gcc/gimplify.c	(working copy)
@@ -6618,10 +6618,12 @@ gimplify_expr (tree *expr_p, gimple_seq 
 				     ? GIMPLE_TRY_FINALLY
 				     : GIMPLE_TRY_CATCH);
 	    if (TREE_CODE (*expr_p) == TRY_CATCH_EXPR)
 	      gimple_try_set_catch_is_cleanup (try_,
 					       TRY_CATCH_IS_CLEANUP (*expr_p));
+	    /* Propagate no_warning flag.  */
+	    gimple_set_no_warning (try_, TREE_NO_WARNING (*expr_p));
 	    gimplify_seq_add_stmt (pre_p, try_);
 	    ret = GS_ALL_DONE;
 	    break;
 	  }
 

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