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