[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / cxx11-exception-spec.cpp
blob3341e29711c8c3a6303fa89f28e7cb97a00f229a
1 // RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t.1
2 // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.1 -emit-pch %s -o %t.2
3 // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -verify %s
4 // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -emit-llvm-only %s
6 // RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch -fpch-instantiate-templates %s -o %t.1
7 // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.1 -emit-pch -fpch-instantiate-templates %s -o %t.2
8 // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -verify %s
9 // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -emit-llvm-only %s
11 // expected-no-diagnostics
13 #ifndef PHASE1_DONE
14 #define PHASE1_DONE
16 template<int n> int f() noexcept(n % 2) { return 0; }
17 template<int n> int g() noexcept(n % 2);
19 decltype(f<2>()) f0;
20 decltype(f<3>()) f1;
21 template int f<4>();
22 template int f<5>();
23 decltype(f<6>()) f6;
24 decltype(f<7>()) f7;
26 struct A {
27 A();
28 A(const A&);
31 decltype(g<0>()) g0;
33 #elif !defined(PHASE2_DONE)
34 #define PHASE2_DONE
36 template int f<6>();
37 template int f<7>();
38 decltype(f<8>()) f8;
39 decltype(f<9>()) f9;
40 template int f<10>();
41 template int f<11>();
43 A::A() = default;
44 A::A(const A&) = default;
46 int g0val = g<0>();
48 #else
50 static_assert(!noexcept(f<0>()), "");
51 static_assert(noexcept(f<1>()), "");
53 #endif