From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/CodeGenCXX/cxx11-exception-spec.cpp | 120 +++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 clang/test/CodeGenCXX/cxx11-exception-spec.cpp (limited to 'clang/test/CodeGenCXX/cxx11-exception-spec.cpp') diff --git a/clang/test/CodeGenCXX/cxx11-exception-spec.cpp b/clang/test/CodeGenCXX/cxx11-exception-spec.cpp new file mode 100644 index 0000000..194b80c --- /dev/null +++ b/clang/test/CodeGenCXX/cxx11-exception-spec.cpp @@ -0,0 +1,120 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -verify -fexceptions -fcxx-exceptions -triple x86_64-linux-gnu | FileCheck %s + +void h(); + +template void f() noexcept(sizeof(T) == 4) { h(); } +template void g() noexcept(sizeof(T) == 4); + +template struct S { + static void f() noexcept(sizeof(T) == 4) { h(); } + static void g() noexcept(sizeof(T) == 4); +}; + +// CHECK: define {{.*}} @_Z1fIsEvv() { +template<> void f() { h(); } +// CHECK: define {{.*}} @_Z1fIA2_sEvv() nounwind { +template<> void f() noexcept { h(); } + +// CHECK: define {{.*}} @_ZN1SIsE1fEv() +// CHECK-NOT: nounwind +template<> void S::f() { h(); } +// CHECK: define {{.*}} @_ZN1SIA2_sE1fEv() nounwind +template<> void S::f() noexcept { h(); } + +// CHECK: define {{.*}} @_Z1fIDsEvv() { +template void f(); +// CHECK: define {{.*}} @_Z1fIA2_DsEvv() nounwind { +template void f(); + +// CHECK: define {{.*}} @_ZN1SIDsE1fEv() +// CHECK-NOT: nounwind +template void S::f(); +// CHECK: define {{.*}} @_ZN1SIA2_DsE1fEv() nounwind +template void S::f(); + +void h() { + // CHECK: define {{.*}} @_Z1fIiEvv() nounwind { + f(); + // CHECK: define {{.*}} @_Z1fIA2_iEvv() { + f(); + + // CHECK: define {{.*}} @_ZN1SIiE1fEv() nounwind + S::f(); + // CHECK: define {{.*}} @_ZN1SIA2_iE1fEv() + // CHECK-NOT: nounwind + S::f(); + + // CHECK: define {{.*}} @_Z1fIfEvv() nounwind { + void (*f1)() = &f; + // CHECK: define {{.*}} @_Z1fIdEvv() { + void (*f2)() = &f; + + // CHECK: define {{.*}} @_ZN1SIfE1fEv() nounwind + void (*f3)() = &S::f; + // CHECK: define {{.*}} @_ZN1SIdE1fEv() + // CHECK-NOT: nounwind + void (*f4)() = &S::f; + + // CHECK: define {{.*}} @_Z1fIA4_cEvv() nounwind { + (void)&f; + // CHECK: define {{.*}} @_Z1fIcEvv() { + (void)&f; + + // CHECK: define {{.*}} @_ZN1SIA4_cE1fEv() nounwind + (void)&S::f; + // CHECK: define {{.*}} @_ZN1SIcE1fEv() + // CHECK-NOT: nounwind + (void)&S::f; +} + +// CHECK: define {{.*}} @_Z1iv +void i() { + // CHECK: declare {{.*}} @_Z1gIiEvv() nounwind + g(); + // CHECK: declare {{.*}} @_Z1gIA2_iEvv() + // CHECK-NOT: nounwind + g(); + + // CHECK: declare {{.*}} @_ZN1SIiE1gEv() nounwind + S::g(); + // CHECK: declare {{.*}} @_ZN1SIA2_iE1gEv() + // CHECK-NOT: nounwind + S::g(); + + // CHECK: declare {{.*}} @_Z1gIfEvv() nounwind + void (*g1)() = &g; + // CHECK: declare {{.*}} @_Z1gIdEvv() + // CHECK-NOT: nounwind + void (*g2)() = &g; + + // CHECK: declare {{.*}} @_ZN1SIfE1gEv() nounwind + void (*g3)() = &S::g; + // CHECK: declare {{.*}} @_ZN1SIdE1gEv() + // CHECK-NOT: nounwind + void (*g4)() = &S::g; + + // CHECK: declare {{.*}} @_Z1gIA4_cEvv() nounwind + (void)&g; + // CHECK: declare {{.*}} @_Z1gIcEvv() + // CHECK-NOT: nounwind + (void)&g; + + // CHECK: declare {{.*}} @_ZN1SIA4_cE1gEv() nounwind + (void)&S::g; + // CHECK: declare {{.*}} @_ZN1SIcE1gEv() + // CHECK-NOT: nounwind + (void)&S::g; +} + +template struct Nested { + template void f() noexcept(sizeof(T) == sizeof(U)); +}; + +// CHECK: define {{.*}} @_Z1jv +void j() { + // CHECK: declare {{.*}} @_ZN6NestedIiE1fILb1EcEEvv( + // CHECK-NOT: nounwind + Nested().f(); + // CHECK: declare {{.*}} @_ZN6NestedIlE1fILb0ElEEvv({{.*}}) nounwind + Nested().f(); +} -- cgit v1.2.3