summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-04-21 19:24:29 +0000
committerBill Wendling <isanbard@gmail.com>2012-04-21 19:24:29 +0000
commiteaa8dfd29ce8f65585390b55e9bfd3b0c8d1eedd (patch)
tree1064945929add358fb331ce52b32f903fde1bb91 /test
parent103f41d0e72a9e52a07e19cbde58c3afc8735098 (diff)
Merging r155279:
------------------------------------------------------------------------ r155279 | chapuni | 2012-04-21 02:40:04 -0700 (Sat, 21 Apr 2012) | 1 line SemaDeclCXX.cpp: Fix utf8 in comment. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@155295 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CodeGenCXX/cxx11-exception-spec.cpp56
-rw-r--r--test/SemaTemplate/instantiate-exception-spec-cxx11.cpp17
2 files changed, 70 insertions, 3 deletions
diff --git a/test/CodeGenCXX/cxx11-exception-spec.cpp b/test/CodeGenCXX/cxx11-exception-spec.cpp
index 4e08dce2ae..194b80cdd4 100644
--- a/test/CodeGenCXX/cxx11-exception-spec.cpp
+++ b/test/CodeGenCXX/cxx11-exception-spec.cpp
@@ -3,9 +3,11 @@
void h();
template<typename T> void f() noexcept(sizeof(T) == 4) { h(); }
+template<typename T> void g() noexcept(sizeof(T) == 4);
template<typename T> struct S {
static void f() noexcept(sizeof(T) == 4) { h(); }
+ static void g() noexcept(sizeof(T) == 4);
};
// CHECK: define {{.*}} @_Z1fIsEvv() {
@@ -30,7 +32,7 @@ template void S<char16_t>::f();
// CHECK: define {{.*}} @_ZN1SIA2_DsE1fEv() nounwind
template void S<char16_t[2]>::f();
-void g() {
+void h() {
// CHECK: define {{.*}} @_Z1fIiEvv() nounwind {
f<int>();
// CHECK: define {{.*}} @_Z1fIA2_iEvv() {
@@ -64,3 +66,55 @@ void g() {
// CHECK-NOT: nounwind
(void)&S<char>::f;
}
+
+// CHECK: define {{.*}} @_Z1iv
+void i() {
+ // CHECK: declare {{.*}} @_Z1gIiEvv() nounwind
+ g<int>();
+ // CHECK: declare {{.*}} @_Z1gIA2_iEvv()
+ // CHECK-NOT: nounwind
+ g<int[2]>();
+
+ // CHECK: declare {{.*}} @_ZN1SIiE1gEv() nounwind
+ S<int>::g();
+ // CHECK: declare {{.*}} @_ZN1SIA2_iE1gEv()
+ // CHECK-NOT: nounwind
+ S<int[2]>::g();
+
+ // CHECK: declare {{.*}} @_Z1gIfEvv() nounwind
+ void (*g1)() = &g<float>;
+ // CHECK: declare {{.*}} @_Z1gIdEvv()
+ // CHECK-NOT: nounwind
+ void (*g2)() = &g<double>;
+
+ // CHECK: declare {{.*}} @_ZN1SIfE1gEv() nounwind
+ void (*g3)() = &S<float>::g;
+ // CHECK: declare {{.*}} @_ZN1SIdE1gEv()
+ // CHECK-NOT: nounwind
+ void (*g4)() = &S<double>::g;
+
+ // CHECK: declare {{.*}} @_Z1gIA4_cEvv() nounwind
+ (void)&g<char[4]>;
+ // CHECK: declare {{.*}} @_Z1gIcEvv()
+ // CHECK-NOT: nounwind
+ (void)&g<char>;
+
+ // CHECK: declare {{.*}} @_ZN1SIA4_cE1gEv() nounwind
+ (void)&S<char[4]>::g;
+ // CHECK: declare {{.*}} @_ZN1SIcE1gEv()
+ // CHECK-NOT: nounwind
+ (void)&S<char>::g;
+}
+
+template<typename T> struct Nested {
+ template<bool b, typename U> void f() noexcept(sizeof(T) == sizeof(U));
+};
+
+// CHECK: define {{.*}} @_Z1jv
+void j() {
+ // CHECK: declare {{.*}} @_ZN6NestedIiE1fILb1EcEEvv(
+ // CHECK-NOT: nounwind
+ Nested<int>().f<true, char>();
+ // CHECK: declare {{.*}} @_ZN6NestedIlE1fILb0ElEEvv({{.*}}) nounwind
+ Nested<long>().f<false, long>();
+}
diff --git a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
index d29c8862b9..8a6f9efa68 100644
--- a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
+++ b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -ftemplate-depth 16 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -ftemplate-depth 16 -fcxx-exceptions -fexceptions %s
// DR1330: an exception specification for a function template is only
// instantiated when it is needed.
@@ -31,7 +31,7 @@ decltype(S<0>::recurse()) *pVoid1 = 0; // ok, exception spec not needed
decltype(&S<0>::recurse) pFn = 0; // ok, exception spec not needed
template<> struct S<10> {};
-void (*pFn2)() noexcept = &S<0>::recurse; // expected-note {{instantiation of exception spec}}
+void (*pFn2)() noexcept = &S<0>::recurse; // expected-note {{instantiation of exception spec}} expected-error {{not superset}}
template<typename T> T go(T a) noexcept(noexcept(go(a))); // \
@@ -118,3 +118,16 @@ namespace pr9485 {
f2(0); // expected-error {{ambiguous}}
}
}
+
+struct Exc1 { char c[4]; };
+struct Exc2 { double x, y, z; };
+struct Base {
+ virtual void f() noexcept; // expected-note {{overridden}}
+};
+template<typename T> struct Derived : Base {
+ void f() noexcept (sizeof(T) == 4); // expected-error {{is more lax}}
+ void g() noexcept (T::error);
+};
+
+Derived<Exc1> d1; // ok
+Derived<Exc2> d2; // expected-note {{in instantiation of}}