]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/noreturn-1.c
3bf62c15b40c10e4b84812e6142ef69a847200e2
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / noreturn-1.c
1 /* Check for various valid and erroneous "noreturn" cases. */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -Wmissing-noreturn" } */
4
5 extern void exit (int);
6
7 extern void foo1(void) __attribute__ ((__noreturn__));
8 void
9 foo1(void)
10 { /* { dg-warning "`noreturn' function does return" "detect falling off end of noreturn" } */
11 }
12
13 extern void foo2(void) __attribute__ ((__noreturn__));
14 void
15 foo2(void)
16 {
17 exit(0);
18 } /* { dg-bogus "warning:" "this function should not get any warnings" } */
19
20 extern void foo3(void);
21 void
22 foo3(void)
23 {
24 } /* { dg-bogus "warning:" "this function should not get any warnings" } */
25
26 extern void foo4(void);
27 void
28 foo4(void)
29 {
30 exit(0);
31 } /* { dg-warning "candidate for attribute `noreturn'" "detect noreturn candidate" } */
32
33 extern void foo5(void) __attribute__ ((__noreturn__));
34 void
35 foo5(void)
36 {
37 return; /* { dg-warning "`noreturn' has a `return' statement" "detect invalid return" } */
38 } /* { dg-warning "`noreturn' function does return" "detect return from noreturn" } */
39
40 extern void foo6(void);
41 void
42 foo6(void)
43 {
44 return;
45 } /* { dg-bogus "warning:" "this function should not get any warnings" } */
46
47 extern void foo7(void);
48 void
49 foo7(void)
50 {
51 foo6();
52 } /* { dg-bogus "warning:" "this function should not get any warnings" } */
53
54 extern void foo8(void) __attribute__ ((__noreturn__));
55 void
56 foo8(void)
57 {
58 foo7();
59 } /* { dg-warning "`noreturn' function does return" "detect return from tail call" } */