• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fsyntax-only %s
2 
3 static void (*fp0)(void) __attribute__((noreturn));
4 
5 void fatal();
6 
f0(void)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() __attribute__((noreturn(1, 2))); // expected-error {{attribute takes no arguments}}
17 
18 void f3() __attribute__((noreturn));
f3()19 void f3() {
20   return;  // expected-warning {{function 'f3' declared 'noreturn' should not return}}
21 }
22 
23 #pragma clang diagnostic error "-Winvalid-noreturn"
24 
25 void f4() __attribute__((noreturn));
f4()26 void f4() {
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
f5(unsigned long size)34 f5 (unsigned long size)
35 {
36 
37 }
38 
39 // PR2461
f(void (* x)(void))40 __attribute__((noreturn)) void f(__attribute__((noreturn)) void (*x)(void)) {
41   x();
42 }
43 
44 typedef void (*Fun)(void) __attribute__ ((noreturn(2))); // expected-error {{attribute takes no arguments}}
45