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 3 4 void h(); 5 6 template<typename T> void f() noexcept(sizeof(T) == 4) { h(); } 7 template<typename T> void g() noexcept(sizeof(T) == 4); 8 9 template<typename T> struct S { 10 static void f() noexcept(sizeof(T) == 4) { h(); } 11 static void g() noexcept(sizeof(T) == 4); 12 }; 13 14 // CHECK: define {{.*}} @_Z1fIsEvv() [[NONE:#[0-9]+]] { 15 template<> void f<short>() { h(); } 16 // CHECK: define {{.*}} @_Z1fIA2_sEvv() [[NUW:#[0-9]+]] { 17 template<> void f<short[2]>() noexcept { h(); } 18 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(); } 24 25 // CHECK: define {{.*}} @_Z1fIDsEvv() [[NONE]] { 26 template void f<char16_t>(); 27 // CHECK: define {{.*}} @_Z1fIA2_DsEvv() [[NUW]] { 28 template void f<char16_t[2]>(); 29 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(); 35 36 void h() { 37 // CHECK: define {{.*}} @_Z1fIiEvv() [[NUW]] { 38 f<int>(); 39 // CHECK: define {{.*}} @_Z1fIA2_iEvv() [[NONE]] { 40 f<int[2]>(); 41 42 // CHECK: define {{.*}} @_ZN1SIiE1fEv() [[NUW]] 43 S<int>::f(); 44 // CHECK: define {{.*}} @_ZN1SIA2_iE1fEv() 45 // CHECK-NOT: [[NUW]] 46 S<int[2]>::f(); 47 48 // CHECK: define {{.*}} @_Z1fIfEvv() [[NUW]] { 49 void (*f1)() = &f<float>; 50 // CHECK: define {{.*}} @_Z1fIdEvv() [[NONE]] { 51 void (*f2)() = &f<double>; 52 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; 58 59 // CHECK: define {{.*}} @_Z1fIA4_cEvv() [[NUW]] { 60 (void)&f<char[4]>; 61 // CHECK: define {{.*}} @_Z1fIcEvv() [[NONE]] { 62 (void)&f<char>; 63 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; 69 } 70 71 // CHECK: define {{.*}} @_Z1iv 72 void i() { 73 // CHECK: declare {{.*}} @_Z1gIiEvv() [[NUW]] 74 g<int>(); 75 // CHECK: declare {{.*}} @_Z1gIA2_iEvv() 76 // CHECK-NOT: [[NUW]] 77 g<int[2]>(); 78 79 // CHECK: declare {{.*}} @_ZN1SIiE1gEv() [[NUW]] 80 S<int>::g(); 81 // CHECK: declare {{.*}} @_ZN1SIA2_iE1gEv() 82 // CHECK-NOT: [[NUW]] 83 S<int[2]>::g(); 84 85 // CHECK: declare {{.*}} @_Z1gIfEvv() [[NUW]] 86 void (*g1)() = &g<float>; 87 // CHECK: declare {{.*}} @_Z1gIdEvv() 88 // CHECK-NOT: [[NUW]] 89 void (*g2)() = &g<double>; 90 91 // CHECK: declare {{.*}} @_ZN1SIfE1gEv() [[NUW]] 92 void (*g3)() = &S<float>::g; 93 // CHECK: declare {{.*}} @_ZN1SIdE1gEv() 94 // CHECK-NOT: [[NUW]] 95 void (*g4)() = &S<double>::g; 96 97 // CHECK: declare {{.*}} @_Z1gIA4_cEvv() [[NUW]] 98 (void)&g<char[4]>; 99 // CHECK: declare {{.*}} @_Z1gIcEvv() 100 // CHECK-NOT: [[NUW]] 101 (void)&g<char>; 102 103 // CHECK: declare {{.*}} @_ZN1SIA4_cE1gEv() [[NUW]] 104 (void)&S<char[4]>::g; 105 // CHECK: declare {{.*}} @_ZN1SIcE1gEv() 106 // CHECK-NOT: [[NUW]] 107 (void)&S<char>::g; 108 } 109 110 template<typename T> struct Nested { 111 template<bool b, typename U> void f() noexcept(sizeof(T) == sizeof(U)); 112 }; 113 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({{.*}}) [[NUW]] 120 Nested<long>().f<false, long>(); 121 } 122 123 // CHECK: attributes [[NONE]] = { {{.*}} } 124 // CHECK: attributes [[NUW]] = { nounwind{{.*}} } 125 126 namespace PR19190 { 127 template <class T> struct DWFIterator { virtual void get() throw(int) = 0; }; 128 void foo(DWFIterator<int> *foo) { foo->get(); } 129 } 130