Testcase for bogus "control reaches end", (-foptimize-sibling-calls)

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Sun Aug 27 05:56:00 GMT 2000


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);
}


More information about the Gcc-patches mailing list