Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -verify -fsyntax-only %s |
Daniel Dunbar | d3f2c10 | 2008-10-19 02:04:16 +0000 | [diff] [blame] | 2 | |
| 3 | static void (*fp0)(void) __attribute__((noreturn)); |
| 4 | |
| 5 | static void __attribute__((noreturn)) f0(void) { |
| 6 | fatal(); |
| 7 | } |
| 8 | |
| 9 | // On K&R |
| 10 | int f1() __attribute__((noreturn)); |
| 11 | |
| 12 | int g0 __attribute__((noreturn)); // expected-warning {{'noreturn' attribute only applies to function types}} |
| 13 | |
| 14 | int f2() __attribute__((noreturn(1, 2))); // expected-error {{attribute requires 0 argument(s)}} |
Mike Stump | f7c41da | 2009-04-29 00:43:21 +0000 | [diff] [blame] | 15 | |
| 16 | void f3() __attribute__((noreturn)); |
Mike Stump | f7c41da | 2009-04-29 00:43:21 +0000 | [diff] [blame] | 17 | void f3() { |
| 18 | return; // expected-error {{function 'f3' declared 'noreturn' should not return}} |
| 19 | } |
| 20 | |
Chris Lattner | 8662587 | 2009-05-31 19:32:13 +0000 | [diff] [blame^] | 21 | #pragma clang diagnostic warning "-Winvalid-noreturn" |
| 22 | |
| 23 | void f4() __attribute__((noreturn)); |
| 24 | void f4() { |
| 25 | return; // expected-warning {{function 'f4' declared 'noreturn' should not return}} |
| 26 | } |
| 27 | |