| 1 |
// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s |
| 2 |
|
| 3 |
// Tests where specs are allowed and where they aren't. |
| 4 |
|
| 5 |
namespace dyn { |
| 6 |
|
| 7 |
// Straight from the standard: |
| 8 |
|
| 9 |
// Plain function with spec |
| 10 |
void f() throw(int); |
| 11 |
|
| 12 |
// Pointer to function with spec |
| 13 |
void (*fp)() throw (int); |
| 14 |
|
| 15 |
// Function taking reference to function with spec |
| 16 |
void g(void pfa() throw(int)); |
| 17 |
|
| 18 |
// Typedef for pointer to function with spec |
| 19 |
typedef int (*pf)() throw(int); // expected-error {{specifications are not allowed in typedefs}} |
| 20 |
|
| 21 |
// Some more: |
| 22 |
|
| 23 |
// Function returning function with spec |
| 24 |
void (*h())() throw(int); |
| 25 |
|
| 26 |
// Ultimate parser thrill: function with spec returning function with spec and |
| 27 |
// taking pointer to function with spec. |
| 28 |
// The actual function throws int, the return type double, the argument float. |
| 29 |
void (*i() throw(int))(void (*)() throw(float)) throw(double); |
| 30 |
|
| 31 |
// Pointer to pointer to function taking function with spec |
| 32 |
void (**k)(void pfa() throw(int)); // no-error |
| 33 |
|
| 34 |
// Pointer to pointer to function with spec |
| 35 |
void (**j)() throw(int); // expected-error {{not allowed beyond a single}} |
| 36 |
|
| 37 |
// Pointer to function returning pointer to pointer to function with spec |
| 38 |
void (**(*h())())() throw(int); // expected-error {{not allowed beyond a single}} |
| 39 |
|
| 40 |
// FIXME: Missing a lot of negative tests, primarily type-ids in various places |
| 41 |
// We fail to diagnose all of those. |
| 42 |
} |
| 43 |
|
| 44 |
namespace noex { |
| 45 |
|
| 46 |
// These parallel those from above. |
| 47 |
|
| 48 |
void f() noexcept(false); |
| 49 |
|
| 50 |
void (*fp)() noexcept(false); |
| 51 |
|
| 52 |
void g(void pfa() noexcept(false)); |
| 53 |
|
| 54 |
typedef int (*pf)() noexcept(false); // expected-error {{specifications are not allowed in typedefs}} |
| 55 |
|
| 56 |
void (*h())() noexcept(false); |
| 57 |
|
| 58 |
void (*i() noexcept(false))(void (*)() noexcept(true)) noexcept(false); |
| 59 |
|
| 60 |
void (**k)(void pfa() noexcept(false)); // no-error |
| 61 |
|
| 62 |
void (**j)() noexcept(false); // expected-error {{not allowed beyond a single}} |
| 63 |
|
| 64 |
void (**(*h())())() noexcept(false); // expected-error {{not allowed beyond a single}} |
| 65 |
} |