1 // RUN: not %clang_cc1 -std=c++11 -emit-llvm %s -o - -verify -fexceptions -fcxx-exceptions -triple x86_64-linux-gnu | FileCheck %s 2 3 void h(); 4 5 template<typename T> void f() noexcept(sizeof(T) == 4) { h(); } 6 template<typename T> void g() noexcept(sizeof(T) == 4); 7 8 template<typename T> struct S { 9 static void f() noexcept(sizeof(T) == 4) { h(); } 10 static void g() noexcept(sizeof(T) == 4); 11 }; 12 13 // CHECK: define {{.*}} @_Z1fIsEvv() [[NONE:#[0-9]+]] { 14 template<> void f<short>() { h(); } 15 // CHECK: define {{.*}} @_Z1fIA2_sEvv() [[NUW:#[0-9]+]] { 16 template<> void f<short[2]>() noexcept { h(); } 17 18 // CHECK: define {{.*}} @_ZN1SIsE1fEv() 19 // CHECK-NOT: [[NUW]] 20 template<> void S<short>::f() { h(); } 21 // CHECK: define {{.*}} @_ZN1SIA2_sE1fEv() [[NUW]] 22 template<> void S<short[2]>::f() noexcept { h(); } 23 24 // CHECK: define {{.*}} @_Z1fIDsEvv() [[NONE]] { 25 template void f<char16_t>(); 26 // CHECK: define {{.*}} @_Z1fIA2_DsEvv() [[NUW]] { 27 template void f<char16_t[2]>(); 28 29 // CHECK: define {{.*}} @_ZN1SIDsE1fEv() 30 // CHECK-NOT: [[NUW]] 31 template void S<char16_t>::f(); 32 // CHECK: define {{.*}} @_ZN1SIA2_DsE1fEv() [[NUW]] 33 template void S<char16_t[2]>::f(); 34 35 void h() { 36 // CHECK: define {{.*}} @_Z1fIiEvv() [[NUW]] { 37 f<int>(); 38 // CHECK: define {{.*}} @_Z1fIA2_iEvv() [[NONE]] { 39 f<int[2]>(); 40 41 // CHECK: define {{.*}} @_ZN1SIiE1fEv() [[NUW]] 42 S<int>::f(); 43 // CHECK: define {{.*}} @_ZN1SIA2_iE1fEv() 44 // CHECK-NOT: [[NUW]] 45 S<int[2]>::f(); 46 47 // CHECK: define {{.*}} @_Z1fIfEvv() [[NUW]] { 48 void (*f1)() = &f<float>; 49 // CHECK: define {{.*}} @_Z1fIdEvv() [[NONE]] { 50 void (*f2)() = &f<double>; 51 52 // CHECK: define {{.*}} @_ZN1SIfE1fEv() [[NUW]] 53 void (*f3)() = &S<float>::f; 54 // CHECK: define {{.*}} @_ZN1SIdE1fEv() 55 // CHECK-NOT: [[NUW]] 56 void (*f4)() = &S<double>::f; 57 58 // CHECK: define {{.*}} @_Z1fIA4_cEvv() [[NUW]] { 59 (void)&f<char[4]>; 60 // CHECK: define {{.*}} @_Z1fIcEvv() [[NONE]] { 61 (void)&f<char>; 62 63 // CHECK: define {{.*}} @_ZN1SIA4_cE1fEv() [[NUW]] 64 (void)&S<char[4]>::f; 65 // CHECK: define {{.*}} @_ZN1SIcE1fEv() 66 // CHECK-NOT: [[NUW]] 67 (void)&S<char>::f; 68 } 69 70 // CHECK: define {{.*}} @_Z1iv 71 void i() { 72 // CHECK: declare {{.*}} @_Z1gIiEvv() [[NUW]] 73 g<int>(); 74 // CHECK: declare {{.*}} @_Z1gIA2_iEvv() 75 // CHECK-NOT: [[NUW]] 76 g<int[2]>(); 77 78 // CHECK: declare {{.*}} @_ZN1SIiE1gEv() [[NUW]] 79 S<int>::g(); 80 // CHECK: declare {{.*}} @_ZN1SIA2_iE1gEv() 81 // CHECK-NOT: [[NUW]] 82 S<int[2]>::g(); 83 84 // CHECK: declare {{.*}} @_Z1gIfEvv() [[NUW]] 85 void (*g1)() = &g<float>; 86 // CHECK: declare {{.*}} @_Z1gIdEvv() 87 // CHECK-NOT: [[NUW]] 88 void (*g2)() = &g<double>; 89 90 // CHECK: declare {{.*}} @_ZN1SIfE1gEv() [[NUW]] 91 void (*g3)() = &S<float>::g; 92 // CHECK: declare {{.*}} @_ZN1SIdE1gEv() 93 // CHECK-NOT: [[NUW]] 94 void (*g4)() = &S<double>::g; 95 96 // CHECK: declare {{.*}} @_Z1gIA4_cEvv() [[NUW]] 97 (void)&g<char[4]>; 98 // CHECK: declare {{.*}} @_Z1gIcEvv() 99 // CHECK-NOT: [[NUW]] 100 (void)&g<char>; 101 102 // CHECK: declare {{.*}} @_ZN1SIA4_cE1gEv() [[NUW]] 103 (void)&S<char[4]>::g; 104 // CHECK: declare {{.*}} @_ZN1SIcE1gEv() 105 // CHECK-NOT: [[NUW]] 106 (void)&S<char>::g; 107 } 108 109 template<typename T> struct Nested { 110 template<bool b, typename U> void f() noexcept(sizeof(T) == sizeof(U)); 111 }; 112 113 // CHECK: define {{.*}} @_Z1jv 114 void j() { 115 // CHECK: declare {{.*}} @_ZN6NestedIiE1fILb1EcEEvv( 116 // CHECK-NOT: [[NUW]] 117 Nested<int>().f<true, char>(); 118 // CHECK: declare {{.*}} @_ZN6NestedIlE1fILb0ElEEvv({{.*}}) [[NUW]] 119 Nested<long>().f<false, long>(); 120 } 121 122 // CHECK: attributes [[NONE]] = { {{.*}} } 123 // CHECK: attributes [[NUW]] = { nounwind{{.*}} } 124