1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s 260618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 360618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl// Tests where specs are allowed and where they aren't. 460618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 560618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redlnamespace dyn { 660618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 760618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // Straight from the standard: 860618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 960618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // Plain function with spec 1060618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void f() throw(int); 1160618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 1260618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // Pointer to function with spec 1360618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (*fp)() throw (int); 1460618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 1560618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // Function taking reference to function with spec 1660618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void g(void pfa() throw(int)); 1760618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 1860618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // Typedef for pointer to function with spec 1960618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl typedef int (*pf)() throw(int); // expected-error {{specifications are not allowed in typedefs}} 2060618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 2160618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // Some more: 2260618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 2360618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // Function returning function with spec 2460618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (*h())() throw(int); 2560618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 2660618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // Ultimate parser thrill: function with spec returning function with spec and 2760618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // taking pointer to function with spec. 2860618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // The actual function throws int, the return type double, the argument float. 2960618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (*i() throw(int))(void (*)() throw(float)) throw(double); 3060618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 3160618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // Pointer to pointer to function taking function with spec 3260618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (**k)(void pfa() throw(int)); // no-error 3360618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 3460618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // Pointer to pointer to function with spec 3560618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (**j)() throw(int); // expected-error {{not allowed beyond a single}} 3660618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 3760618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // Pointer to function returning pointer to pointer to function with spec 3860618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (**(*h())())() throw(int); // expected-error {{not allowed beyond a single}} 3960618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 4060618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl} 4160618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 4260618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redlnamespace noex { 4360618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 4460618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl // These parallel those from above. 4560618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 4660618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void f() noexcept(false); 4760618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 4860618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (*fp)() noexcept(false); 4960618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 5060618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void g(void pfa() noexcept(false)); 5160618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 5260618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl typedef int (*pf)() noexcept(false); // expected-error {{specifications are not allowed in typedefs}} 5360618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 5460618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (*h())() noexcept(false); 5560618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 5660618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (*i() noexcept(false))(void (*)() noexcept(true)) noexcept(false); 5760618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 5860618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (**k)(void pfa() noexcept(false)); // no-error 5960618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 6060618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (**j)() noexcept(false); // expected-error {{not allowed beyond a single}} 6160618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl 6260618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl void (**(*h())())() noexcept(false); // expected-error {{not allowed beyond a single}} 6360618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl} 64