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