]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/13394 (noreturn attribute ignored on recursive invokation)
authorEric Botcazou <ebotcazou@libertysurf.fr>
Tue, 23 Dec 2003 05:32:02 +0000 (06:32 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 23 Dec 2003 05:32:02 +0000 (05:32 +0000)
PR optimization/13394
* toplev.c (rest_of_compilation): Move call to
check_function_return_warnings right after the sibcall
optimization pass.

From-SVN: r74961

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/noreturn-7.c [new file with mode: 0644]
gcc/toplev.c

index 81b80dff928b3e3bdf9d7048aabb1cbfd2d8592f..f87dbac34baf2afa7de803eaf14866c4121195b6 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-23  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR optimization/13394
+       * toplev.c (rest_of_compilation): Move call to
+       check_function_return_warnings right after the sibcall
+       optimization pass.
+
 2003-12-23  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR c/13382
index bf06beaf5afa5d8d724fc4342905133c194b706a..9095c8a4dc58f4058a74bccd90b9b2c0c541ca1b 100644 (file)
@@ -1,3 +1,7 @@
+2003-12-23  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * gcc.dg/noreturn-7.c: New test.
+
 2003-12-23  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/null-pointer-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/noreturn-7.c b/gcc/testsuite/gcc.dg/noreturn-7.c
new file mode 100644 (file)
index 0000000..1d94a7c
--- /dev/null
@@ -0,0 +1,42 @@
+/* PR optimization/13394 */
+/* Origin: Carlo Wood <carlo@gcc.gnu.org> */
+
+/* Verify that a bogus "function does return" warning is not issued
+   in presence of tail recursion within a noreturn function.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wreturn-type -Wmissing-noreturn" } */
+
+
+void f(void) __attribute__ ((__noreturn__));
+void _exit(int status) __attribute__ ((__noreturn__));
+
+int z = 0;
+
+void g()
+{
+  if (++z > 10)
+    _exit(0);
+  g();
+}             /* { dg-warning "possible candidate" } */
+
+void f()
+{
+  if (++z > 10)
+    _exit(0);
+  f();
+}             /* { dg-bogus "does return" } */
+
+int h()
+{
+  if (++z > 10)
+    _exit(0);
+  return h();
+}             /* { dg-bogus "end of non-void function" } */
+
+int k()
+{
+  if (++z > 10)
+    _exit(0);
+  k();
+}             /* { dg-warning "end of non-void function" } */
index 2ed4c31ac5c67ee837bcbbd1901576290fbec75f..7d01eb6dc1c84f198019dfb66a055e07e71d4a89 100644 (file)
@@ -3144,10 +3144,6 @@ rest_of_compilation (tree decl)
 
   delete_unreachable_blocks ();
 
-  /* We have to issue these warnings now already, because CFG cleanups
-     further down may destroy the required information.  */
-  check_function_return_warnings ();
-
   /* Turn NOTE_INSN_PREDICTIONs into branch predictions.  */
   if (flag_guess_branch_prob)
     {
@@ -3159,6 +3155,14 @@ rest_of_compilation (tree decl)
   if (flag_optimize_sibling_calls)
     rest_of_handle_sibling_calls (insns);
 
+  /* We have to issue these warnings now already, because CFG cleanups
+     further down may destroy the required information.  However, this
+     must be done after the sibcall optimization pass because the barrier
+     emitted for noreturn calls that are candidate for the optimization
+     is folded into the CALL_PLACEHOLDER until after this pass, so the
+     CFG is inaccurate.  */
+  check_function_return_warnings ();
+
   timevar_pop (TV_JUMP);
 
   insn_locators_initialize ();