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