OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / return-type-2.c
1 /* Bogus warnings claiming we fall off the end of a non-void function.
2    By Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 8/27/2000.  */
3 /* { dg-do compile } */
4 /* { dg-options "-O2 -Wreturn-type" } */
5
6 extern void abort (void) __attribute__ ((__noreturn__));
7
8 int
9 foo1 (int i)
10 {
11   if (i)
12     return i;
13
14   abort ();
15 } /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */
16
17 __inline__ int
18 foo2 (int i)
19 {
20   if (i)
21     return i;
22
23   abort ();
24 } /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */
25
26 static int
27 foo3 (int i)
28 {
29   if (i)
30     return i;
31
32   abort ();
33 } /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */
34
35 static __inline__ int
36 foo4 (int i)
37 {
38   if (i)
39     return i;
40
41   abort ();
42 } /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */
43
44 int bar (int i)
45 {
46   return foo1 (i) + foo2 (i) + foo3 (i) + foo4 (i);
47 }