PR tree-optimization/83369 - Missing diagnostics during inlining
[official-gcc.git] / gcc / testsuite / gcc.dg / c11-noreturn-1.c
blob1b0c218b08b967118826cfa1d47c481431452c7f
1 /* Test C11 _Noreturn. Test valid code. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c11 -pedantic-errors" } */
5 _Noreturn void exit (int);
7 _Noreturn int f1 (void);
9 _Noreturn void f2 (void);
11 static void _Noreturn f3 (void) { exit (0); }
13 /* Returning from a noreturn function is undefined at runtime, not a
14 constraint violation, but recommended practice is to diagnose if
15 such a return appears possible. */
17 _Noreturn int
18 f4 (void)
20 return 1; /* { dg-warning "has a 'return' statement" } */
21 /* { dg-warning "does return" "second warning" { target *-*-* } .-1 } */
24 _Noreturn void
25 f5 (void)
27 return; /* { dg-warning "has a 'return' statement" } */
28 /* { dg-warning "does return" "second warning" { target *-*-* } .-1 } */
31 _Noreturn void
32 f6 (void)
34 } /* { dg-warning "does return" } */
36 _Noreturn void
37 f7 (int a)
39 if (a)
40 exit (0);
41 } /* { dg-warning "does return" } */
43 /* Declarations need not all have _Noreturn. */
45 void f2 (void);
47 void f8 (void);
48 _Noreturn void f8 (void);
50 /* Duplicate _Noreturn is OK. */
51 _Noreturn _Noreturn void _Noreturn f9 (void);
53 /* _Noreturn does not affect type compatibility. */
55 void (*fp) (void) = f5;
57 /* noreturn is an ordinary identifier. */
59 int noreturn;