Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / cxx11-exception-spec.cpp
blob08de8868b47100962d040b4109027c5db52a151b
1 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -verify -fexceptions -fcxx-exceptions -triple x86_64-linux-gnu | FileCheck %s
2 // expected-no-diagnostics
4 void h();
6 template<typename T> void f() noexcept(sizeof(T) == 4) { h(); }
7 template<typename T> void g() noexcept(sizeof(T) == 4);
9 template<typename T> struct S {
10 static void f() noexcept(sizeof(T) == 4) { h(); }
11 static void g() noexcept(sizeof(T) == 4);
14 // CHECK: define {{.*}} @_Z1fIsEvv() [[NONE:#[0-9]+]] {
15 template<> void f<short>() { h(); }
16 // CHECK: define {{.*}} @_Z1fIA2_sEvv() [[NUW:#[0-9]+]] personality ptr @__gxx_personality_v0 {
17 template<> void f<short[2]>() noexcept { h(); }
19 // CHECK: define {{.*}} @_ZN1SIsE1fEv()
20 // CHECK-NOT: [[NUW]]
21 template<> void S<short>::f() { h(); }
22 // CHECK: define {{.*}} @_ZN1SIA2_sE1fEv() [[NUW]]
23 template<> void S<short[2]>::f() noexcept { h(); }
25 // CHECK: define {{.*}} @_Z1fIDsEvv() [[NONE]] comdat {
26 template void f<char16_t>();
27 // CHECK: define {{.*}} @_Z1fIA2_DsEvv() [[NUW]] comdat personality ptr @__gxx_personality_v0 {
28 template void f<char16_t[2]>();
30 // CHECK: define {{.*}} @_ZN1SIDsE1fEv()
31 // CHECK-NOT: [[NUW]]
32 template void S<char16_t>::f();
33 // CHECK: define {{.*}} @_ZN1SIA2_DsE1fEv() [[NUW]]
34 template void S<char16_t[2]>::f();
36 void h() {
37 // CHECK: define {{.*}} @_Z1fIiEvv() [[NUW]] comdat personality ptr @__gxx_personality_v0 {
38 f<int>();
39 // CHECK: define {{.*}} @_Z1fIA2_iEvv() [[NONE]] comdat {
40 f<int[2]>();
42 // CHECK: define {{.*}} @_ZN1SIiE1fEv() [[NUW]]
43 S<int>::f();
44 // CHECK: define {{.*}} @_ZN1SIA2_iE1fEv()
45 // CHECK-NOT: [[NUW]]
46 S<int[2]>::f();
48 // CHECK: define {{.*}} @_Z1fIfEvv() [[NUW]] comdat personality ptr @__gxx_personality_v0 {
49 void (*f1)() = &f<float>;
50 // CHECK: define {{.*}} @_Z1fIdEvv() [[NONE]] comdat {
51 void (*f2)() = &f<double>;
53 // CHECK: define {{.*}} @_ZN1SIfE1fEv() [[NUW]]
54 void (*f3)() = &S<float>::f;
55 // CHECK: define {{.*}} @_ZN1SIdE1fEv()
56 // CHECK-NOT: [[NUW]]
57 void (*f4)() = &S<double>::f;
59 // CHECK: define {{.*}} @_Z1fIA4_cEvv() [[NUW]] comdat personality ptr @__gxx_personality_v0 {
60 (void)&f<char[4]>;
61 // CHECK: define {{.*}} @_Z1fIcEvv() [[NONE]] comdat {
62 (void)&f<char>;
64 // CHECK: define {{.*}} @_ZN1SIA4_cE1fEv() [[NUW]]
65 (void)&S<char[4]>::f;
66 // CHECK: define {{.*}} @_ZN1SIcE1fEv()
67 // CHECK-NOT: [[NUW]]
68 (void)&S<char>::f;
71 // CHECK: define {{.*}} @_Z1iv
72 void i() {
73 // CHECK: declare {{.*}} @_Z1gIiEvv() [[NUW2:#[0-9]+]]
74 g<int>();
75 // CHECK: declare {{.*}} @_Z1gIA2_iEvv()
76 // CHECK-NOT: [[NUW]]
77 g<int[2]>();
79 // CHECK: declare {{.*}} @_ZN1SIiE1gEv() [[NUW2]]
80 S<int>::g();
81 // CHECK: declare {{.*}} @_ZN1SIA2_iE1gEv()
82 // CHECK-NOT: [[NUW]]
83 S<int[2]>::g();
85 // CHECK: declare {{.*}} @_Z1gIfEvv() [[NUW2]]
86 void (*g1)() = &g<float>;
87 // CHECK: declare {{.*}} @_Z1gIdEvv()
88 // CHECK-NOT: [[NUW]]
89 void (*g2)() = &g<double>;
91 // CHECK: declare {{.*}} @_ZN1SIfE1gEv() [[NUW2]]
92 void (*g3)() = &S<float>::g;
93 // CHECK: declare {{.*}} @_ZN1SIdE1gEv()
94 // CHECK-NOT: [[NUW]]
95 void (*g4)() = &S<double>::g;
97 // CHECK: declare {{.*}} @_Z1gIA4_cEvv() [[NUW2]]
98 (void)&g<char[4]>;
99 // CHECK: declare {{.*}} @_Z1gIcEvv()
100 // CHECK-NOT: [[NUW]]
101 (void)&g<char>;
103 // CHECK: declare {{.*}} @_ZN1SIA4_cE1gEv() [[NUW2]]
104 (void)&S<char[4]>::g;
105 // CHECK: declare {{.*}} @_ZN1SIcE1gEv()
106 // CHECK-NOT: [[NUW]]
107 (void)&S<char>::g;
110 template<typename T> struct Nested {
111 template<bool b, typename U> void f() noexcept(sizeof(T) == sizeof(U));
114 // CHECK: define {{.*}} @_Z1jv
115 void j() {
116 // CHECK: declare {{.*}} @_ZN6NestedIiE1fILb1EcEEvv(
117 // CHECK-NOT: [[NUW]]
118 Nested<int>().f<true, char>();
119 // CHECK: declare {{.*}} @_ZN6NestedIlE1fILb0ElEEvv({{.*}}) [[NUW2]]
120 Nested<long>().f<false, long>();
123 // CHECK: attributes [[NONE]] = { {{.*}} }
124 // CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} }
125 // CHECK: attributes [[NUW2]] = { nounwind{{.*}} }
129 namespace PR19190 {
130 template <class T> struct DWFIterator { virtual void get() throw(int) = 0; };
131 void foo(DWFIterator<int> *foo) { foo->get(); }