| 1 |
// RUN: %clang_cc1 -verify -Wno-strict-prototypes -fsyntax-only %s |
| 2 |
|
| 3 |
static void (*fp0)(void) __attribute__((noreturn)); |
| 4 |
|
| 5 |
void fatal(void); |
| 6 |
|
| 7 |
static void __attribute__((noreturn)) f0(void) { |
| 8 |
fatal(); |
| 9 |
} // expected-warning {{function declared 'noreturn' should not return}} |
| 10 |
|
| 11 |
// On K&R |
| 12 |
int f1() __attribute__((noreturn)); |
| 13 |
|
| 14 |
int g0 __attribute__((noreturn)); // expected-warning {{'noreturn' only applies to function types; type here is 'int'}} |
| 15 |
|
| 16 |
int f2(void) __attribute__((noreturn(1, 2))); // expected-error {{'noreturn' attribute takes no arguments}} |
| 17 |
|
| 18 |
void f3(void) __attribute__((noreturn)); |
| 19 |
void f3(void) { |
| 20 |
return; // expected-warning {{function 'f3' declared 'noreturn' should not return}} |
| 21 |
} |
| 22 |
|
| 23 |
#pragma clang diagnostic error "-Winvalid-noreturn" |
| 24 |
|
| 25 |
void f4(void) __attribute__((noreturn)); |
| 26 |
void f4(void) { |
| 27 |
return; // expected-error {{function 'f4' declared 'noreturn' should not return}} |
| 28 |
} |
| 29 |
|
| 30 |
// PR4685 |
| 31 |
extern void f5 (unsigned long) __attribute__ ((__noreturn__)); |
| 32 |
|
| 33 |
void |
| 34 |
f5 (unsigned long size) |
| 35 |
{ |
| 36 |
|
| 37 |
} |
| 38 |
|
| 39 |
// PR2461 |
| 40 |
__attribute__((noreturn)) void f(__attribute__((noreturn)) void (*x)(void)) { |
| 41 |
x(); |
| 42 |
} |
| 43 |
|
| 44 |
typedef void (*Fun)(void) __attribute__ ((noreturn(2))); // expected-error {{'noreturn' attribute takes no arguments}} |
| 45 |
|
| 46 |
|
| 47 |
typedef void fn_t(void); |
| 48 |
|
| 49 |
fn_t *fp __attribute__((noreturn)); |
| 50 |
void __attribute__((noreturn)) f6(int i) { |
| 51 |
fp(); |
| 52 |
} |
| 53 |
|
| 54 |
fn_t *fps[4] __attribute__((noreturn)); |
| 55 |
void __attribute__((noreturn)) f7(int i) { |
| 56 |
fps[i](); |
| 57 |
} |
| 58 |
|
| 59 |
extern fn_t *ifps[] __attribute__((noreturn)); |
| 60 |
void __attribute__((noreturn)) f8(int i) { |
| 61 |
ifps[i](); |
| 62 |
} |
| 63 |
|
| 64 |
void __attribute__((noreturn)) f9(int n) { |
| 65 |
extern int g9(int, fn_t **); |
| 66 |
fn_t *fp[n] __attribute__((noreturn)); |
| 67 |
int i = g9(n, fp); |
| 68 |
fp[i](); |
| 69 |
} |
| 70 |
|
| 71 |
typedef fn_t *fptrs_t[4]; |
| 72 |
fptrs_t ps __attribute__((noreturn)); |
| 73 |
void __attribute__((noreturn)) f10(int i) { |
| 74 |
ps[i](); |
| 75 |
} |