[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / except / except.spec / p2-places.cpp
blobea842af898459fead0d45ce1cf5c01bb4d3aa4f0
1 // RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
3 // Tests where specs are allowed and where they aren't.
5 namespace dyn {
7 // Straight from the standard:
9 // Plain function with spec
10 void f() throw(int);
12 // Pointer to function with spec
13 void (*fp)() throw (int);
15 // Function taking reference to function with spec
16 void g(void pfa() throw(int));
18 // Typedef for pointer to function with spec
19 typedef int (*pf)() throw(int); // expected-error {{specifications are not allowed in typedefs}}
21 // Some more:
23 // Function returning function with spec
24 void (*h())() throw(int);
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);
31 // Pointer to pointer to function taking function with spec
32 void (**k)(void pfa() throw(int)); // no-error
34 // Pointer to pointer to function with spec
35 void (**j)() throw(int); // expected-error {{not allowed beyond a single}}
37 // Pointer to function returning pointer to pointer to function with spec
38 void (**(*h())())() throw(int); // expected-error {{not allowed beyond a single}}
40 // FIXME: Missing a lot of negative tests, primarily type-ids in various places
41 // We fail to diagnose all of those.
44 namespace noex {
46 // These parallel those from above.
48 void f() noexcept(false);
50 void (*fp)() noexcept(false);
52 void g(void pfa() noexcept(false));
54 typedef int (*pf)() noexcept(false); // expected-error {{specifications are not allowed in typedefs}}
56 void (*h())() noexcept(false);
58 void (*i() noexcept(false))(void (*)() noexcept(true)) noexcept(false);
60 void (**k)(void pfa() noexcept(false)); // no-error
62 void (**j)() noexcept(false); // expected-error {{not allowed beyond a single}}
64 void (**(*h())())() noexcept(false); // expected-error {{not allowed beyond a single}}