[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / attr-noreturn.c
blobc617c19ff33ec04147d0ac0d37f79e4e388cd81e
1 // RUN: %clang_cc1 -verify -Wno-strict-prototypes -fsyntax-only %s
3 static void (*fp0)(void) __attribute__((noreturn));
5 void fatal(void);
7 static void __attribute__((noreturn)) f0(void) {
8 fatal();
9 } // expected-warning {{function declared 'noreturn' should not return}}
11 // On K&R
12 int f1() __attribute__((noreturn));
14 int g0 __attribute__((noreturn)); // expected-warning {{'noreturn' only applies to function types; type here is 'int'}}
16 int f2(void) __attribute__((noreturn(1, 2))); // expected-error {{'noreturn' attribute takes no arguments}}
18 void f3(void) __attribute__((noreturn));
19 void f3(void) {
20 return; // expected-warning {{function 'f3' declared 'noreturn' should not return}}
23 #pragma clang diagnostic error "-Winvalid-noreturn"
25 void f4(void) __attribute__((noreturn));
26 void f4(void) {
27 return; // expected-error {{function 'f4' declared 'noreturn' should not return}}
30 // PR4685
31 extern void f5 (unsigned long) __attribute__ ((__noreturn__));
33 void
34 f5 (unsigned long size)
39 // PR2461
40 __attribute__((noreturn)) void f(__attribute__((noreturn)) void (*x)(void)) {
41 x();
44 typedef void (*Fun)(void) __attribute__ ((noreturn(2))); // expected-error {{'noreturn' attribute takes no arguments}}
47 typedef void fn_t(void);
49 fn_t *fp __attribute__((noreturn));
50 void __attribute__((noreturn)) f6(int i) {
51 fp();
54 fn_t *fps[4] __attribute__((noreturn));
55 void __attribute__((noreturn)) f7(int i) {
56 fps[i]();
59 extern fn_t *ifps[] __attribute__((noreturn));
60 void __attribute__((noreturn)) f8(int i) {
61 ifps[i]();
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]();
71 typedef fn_t *fptrs_t[4];
72 fptrs_t ps __attribute__((noreturn));
73 void __attribute__((noreturn)) f10(int i) {
74 ps[i]();