1 /* Test C1X _Noreturn. Test valid code using stdnoreturn.h. */
3 /* { dg-options "-std=c1x -pedantic-errors" } */
5 #include <stdnoreturn.h>
7 extern int strcmp (const char *, const char *);
9 noreturn
void exit (int);
10 noreturn
void abort (void);
12 noreturn
int f1 (void);
14 noreturn
void f2 (void);
16 static void noreturn
f3 (void) { exit (0); }
18 /* Returning from a noreturn function is undefined at runtime, not a
19 constraint violation, but recommended practice is to diagnose if
20 such a return appears possible. */
25 return 1; /* { dg-warning "has a 'return' statement" } */
26 /* { dg-warning "does return" "second warning" { target *-*-* } 25 } */
32 return; /* { dg-warning "has a 'return' statement" } */
33 /* { dg-warning "does return" "second warning" { target *-*-* } 32 } */
39 } /* { dg-warning "does return" } */
46 } /* { dg-warning "does return" } */
48 /* Declarations need not all have noreturn. */
53 noreturn
void f8 (void);
55 /* Duplicate noreturn is OK. */
56 noreturn noreturn
void noreturn
f9 (void);
58 /* noreturn does not affect type compatibility. */
60 void (*fp
) (void) = f5
;
63 #error "noreturn not defined"
67 #define xstr(x) str(x)
69 const char *s
= xstr(noreturn
);
74 if (strcmp (s
, "_Noreturn") != 0)