tail call breaks return/noreturn calculation

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Tue Mar 21 12:00:00 GMT 2000


I think the recent tail call work has broken the return/noreturn
detection.  If I bootstrap with -Wmissing-noreturn, functions which
end with a returning tail call wrongly trigger the "might be candidate
for attribute noreturn" warning.  Conversely, noreturn functions which
end in a returning tail call fail to warn that the function might
return.  (These both require -O2 to happen.)

I've extended the gcc.dg/noreturn-1.c test to expose this problem.
The new portion of the test triggers for me on x86, but not on sparc,
correlating with platforms where tail call opts are activated in CVS
as of today. (?)

		--Kaveh


===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/gcc.dg/noreturn-1.c,v
retrieving revision 1.2
retrieving revision 1.4
diff -u -r1.2 -r1.4
--- egcs/gcc/testsuite/gcc.dg/noreturn-1.c      1999/09/04 15:09:14     1.2
+++ egcs/gcc/testsuite/gcc.dg/noreturn-1.c      2000/03/21 19:08:19     1.4
@@ -1,6 +1,6 @@
 /* Check for various valid and erroneous "noreturn" cases. */
 /* { dg-do compile } */
-/* { dg-options "-O -Wmissing-noreturn" } */
+/* { dg-options "-O2 -Wmissing-noreturn" } */
 
 extern void foo1(void) __attribute__ ((__noreturn__));
 void
@@ -41,3 +41,17 @@
 {
   return;
 } /* { dg-bogus "warning:" "this function should not get any warnings" } */
+
+extern void foo7(void);
+void
+foo7(void)
+{
+  foo6();
+} /* { dg-bogus "warning:" "this function should not get any warnings" } */
+
+extern void foo8(void) __attribute__ ((__noreturn__));
+void
+foo8(void)
+{
+  foo7();
+} /* { dg-warning "`noreturn' function does return" "detect return from tail call" } */

--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions


More information about the Gcc-patches mailing list