Sebastian Redl | 6a7330c | 2009-05-29 15:01:05 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | // Straight from the standard: |
| 4 | // Plain function with spec |
| 5 | void f() throw(int); |
| 6 | // Pointer to function with spec |
| 7 | void (*fp)() throw (int); |
| 8 | // Function taking reference to function with spec |
| 9 | void g(void pfa() throw(int)); |
| 10 | // Typedef for pointer to function with spec |
| 11 | typedef int (*pf)() throw(int); // xpected-error spec-on-typedef |
| 12 | |
| 13 | // Some more: |
| 14 | // Function returning function with spec |
| 15 | void (*h())() throw(int); |
| 16 | // Ultimate parser thrill: function with spec returning function with spec and |
| 17 | // taking pointer to function with spec. |
| 18 | // The actual function throws int, the return type double, the argument float. |
| 19 | void (*i() throw(int))(void (*)() throw(float)) throw(double); |
| 20 | // Pointer to pointer to function taking function with spec |
| 21 | void (**k)(void pfa() throw(int)); // no-error |
| 22 | // Pointer to pointer to function with spec |
| 23 | void (**j)() throw(int); // expected-error {{not allowed beyond a single}} |
| 24 | // Pointer to function returning pointer to pointer to function with spec |
| 25 | void (**(*h())())() throw(int); // expected-error {{not allowed beyond a single}} |
Sebastian Redl | ef65f06 | 2009-05-29 18:02:33 +0000 | [diff] [blame^] | 26 | |
| 27 | struct Incomplete; |
| 28 | |
| 29 | // Exception spec must not have incomplete types, or pointers to them, except |
| 30 | // void. |
| 31 | void ic1() throw(void); // expected-error {{incomplete type 'void' is not allowed in exception specification}} |
| 32 | void ic2() throw(Incomplete); // expected-error {{incomplete type 'struct Incomplete' is not allowed in exception specification}} |
| 33 | void ic3() throw(void*); |
| 34 | void ic4() throw(Incomplete*); // expected-error {{pointer to incomplete type 'struct Incomplete' is not allowed in exception specification}} |
| 35 | void ic5() throw(Incomplete&); // expected-error {{reference to incomplete type 'struct Incomplete' is not allowed in exception specification}} |