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