xref: /aosp_15_r20/external/clang/test/PCH/cxx11-exception-spec.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t.1
2*67e74705SXin Li // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.1 -emit-pch %s -o %t.2
3*67e74705SXin Li // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -verify %s
4*67e74705SXin Li // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -emit-llvm-only %s
5*67e74705SXin Li // expected-no-diagnostics
6*67e74705SXin Li 
7*67e74705SXin Li #ifndef PHASE1_DONE
8*67e74705SXin Li #define PHASE1_DONE
9*67e74705SXin Li 
f()10*67e74705SXin Li template<int n> int f() noexcept(n % 2) { return 0; }
11*67e74705SXin Li template<int n> int g() noexcept(n % 2);
12*67e74705SXin Li 
13*67e74705SXin Li decltype(f<2>()) f0;
14*67e74705SXin Li decltype(f<3>()) f1;
15*67e74705SXin Li template int f<4>();
16*67e74705SXin Li template int f<5>();
17*67e74705SXin Li decltype(f<6>()) f6;
18*67e74705SXin Li decltype(f<7>()) f7;
19*67e74705SXin Li 
20*67e74705SXin Li struct A {
21*67e74705SXin Li   A();
22*67e74705SXin Li   A(const A&);
23*67e74705SXin Li };
24*67e74705SXin Li 
25*67e74705SXin Li decltype(g<0>()) g0;
26*67e74705SXin Li 
27*67e74705SXin Li #elif !defined(PHASE2_DONE)
28*67e74705SXin Li #define PHASE2_DONE
29*67e74705SXin Li 
30*67e74705SXin Li template int f<6>();
31*67e74705SXin Li template int f<7>();
32*67e74705SXin Li decltype(f<8>()) f8;
33*67e74705SXin Li decltype(f<9>()) f9;
34*67e74705SXin Li template int f<10>();
35*67e74705SXin Li template int f<11>();
36*67e74705SXin Li 
37*67e74705SXin Li A::A() = default;
38*67e74705SXin Li A::A(const A&) = default;
39*67e74705SXin Li 
40*67e74705SXin Li int g0val = g<0>();
41*67e74705SXin Li 
42*67e74705SXin Li #else
43*67e74705SXin Li 
44*67e74705SXin Li static_assert(!noexcept(f<0>()), "");
45*67e74705SXin Li static_assert(noexcept(f<1>()), "");
46*67e74705SXin Li 
47*67e74705SXin Li #endif
48