This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Testcase for bogus "control reaches end", (-foptimize-sibling-calls)
- To: gcc-bugs at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Subject: Testcase for bogus "control reaches end", (-foptimize-sibling-calls)
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Sun, 27 Aug 2000 08:56:49 -0400 (EDT)
On solaris2.7, I'm getting bogus "control reaches end of non-void
function" warnings in dwarf2out.c.
> dwarf2out.c:4129: warning: control reaches end of non-void function
> dwarf2out.c:4157: warning: control reaches end of non-void function
> dwarf2out.c:4185: warning: control reaches end of non-void function
> dwarf2out.c:4251: warning: control reaches end of non-void function
> dwarf2out.c:4279: warning: control reaches end of non-void function
> dwarf2out.c:4324: warning: control reaches end of non-void function
> dwarf2out.c:4352: warning: control reaches end of non-void function
> dwarf2out.c:4398: warning: control reaches end of non-void function
They occur on functions which look like this:
> static __inline__ int
> foo (int i)
> {
> if (i)
> return i;
>
> abort ();
> }
The __inline__ keyword is necessary to trigger it. You also need to
pass -O2, (or "-O -foptimize-sibling-calls",) plus -Wreturn-type.
I created the following testcase. Okay to install?
--Kaveh
/* Bogus warnings claiming we fall off the end of a non-void function.
By Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 8/27/2000. */
/* { dg-do compile } */
/* { dg-options "-O2 -Wreturn-type" } */
extern void abort (void) __attribute__ ((__noreturn__));
int
foo1 (int i)
{
if (i)
return i;
abort ();
} /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */
__inline__ int
foo2 (int i)
{
if (i)
return i;
abort ();
} /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */
static int
foo3 (int i)
{
if (i)
return i;
abort ();
} /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */
static __inline__ int
foo4 (int i)
{
if (i)
return i;
abort ();
} /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */
int bar (int i)
{
return foo1 (i) + foo2 (i) + foo3 (i) + foo4 (i);
}