attr-noreturn.c revision 9dc9c376a9f3e0c72f33e27075caa0647dadb350
1// RUN: clang-cc -verify -fsyntax-only %s 2 3static void (*fp0)(void) __attribute__((noreturn)); 4 5static void __attribute__((noreturn)) f0(void) { 6 fatal(); 7} // expected-warning {{function declared 'noreturn' should not return}} 8 9// On K&R 10int f1() __attribute__((noreturn)); 11 12int g0 __attribute__((noreturn)); // expected-warning {{'noreturn' attribute only applies to function types}} 13 14int f2() __attribute__((noreturn(1, 2))); // expected-error {{attribute requires 0 argument(s)}} 15 16void f3() __attribute__((noreturn)); 17void f3() { 18 return; // expected-warning {{function 'f3' declared 'noreturn' should not return}} 19} 20 21#pragma clang diagnostic error "-Winvalid-noreturn" 22 23void f4() __attribute__((noreturn)); 24void f4() { 25 return; // expected-error {{function 'f4' declared 'noreturn' should not return}} 26} 27 28// PR4685 29extern void f5 (unsigned long) __attribute__ ((__noreturn__)); 30 31void 32f5 (unsigned long size) 33{ 34 35} 36