Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 43c79c2 | 2009-12-09 00:47:37 +0000 | [diff] [blame] | 2 | |
| 3 | // PR5620 |
| 4 | void f0() __attribute__((__noreturn__)); |
| 5 | void f1(void (*)()); |
| 6 | void f2() { f1(f0); } |
| 7 | |
| 8 | // Taking the address of a noreturn function |
| 9 | void test_f0a() { |
| 10 | void (*fp)() = f0; |
| 11 | void (*fp1)() __attribute__((noreturn)) = f0; |
| 12 | } |
| 13 | |
| 14 | // Taking the address of an overloaded noreturn function |
| 15 | void f0(int) __attribute__((__noreturn__)); |
| 16 | |
| 17 | void test_f0b() { |
| 18 | void (*fp)() = f0; |
| 19 | void (*fp1)() __attribute__((noreturn)) = f0; |
| 20 | } |
| 21 | |
| 22 | // No-returned function pointers |
| 23 | typedef void (* noreturn_fp)() __attribute__((noreturn)); |
| 24 | |
| 25 | void f3(noreturn_fp); // expected-note{{candidate function}} |
| 26 | |
| 27 | void test_f3() { |
| 28 | f3(f0); // okay |
| 29 | f3(f2); // expected-error{{no matching function for call}} |
| 30 | } |
Nuno Lopes | f75b830 | 2009-12-23 23:40:33 +0000 | [diff] [blame^] | 31 | |
| 32 | |
| 33 | class xpto { |
| 34 | int blah() __attribute__((noreturn)); |
| 35 | }; |
| 36 | |
| 37 | int xpto::blah() { |
| 38 | return 3; // expected-warning {{function 'blah' declared 'noreturn' should not return}} |
| 39 | } |