summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/except/except.spec/p1.cpp9
-rw-r--r--clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp34
-rw-r--r--clang/test/SemaTemplate/instantiate-exception-spec.cpp21
3 files changed, 62 insertions, 2 deletions
diff --git a/clang/test/CXX/except/except.spec/p1.cpp b/clang/test/CXX/except/except.spec/p1.cpp
index a32f37d5520..fa53c9f5d23 100644
--- a/clang/test/CXX/except/except.spec/p1.cpp
+++ b/clang/test/CXX/except/except.spec/p1.cpp
@@ -77,5 +77,12 @@ namespace PR11084 {
static int f() noexcept(1/X) { return 10; } // expected-error{{argument to noexcept specifier must be a constant expression}} expected-note{{division by zero}}
};
- void g() { A<0>::f(); } // expected-note{{in instantiation of exception specification for 'f' requested here}}
+ template<int X> void f() {
+ int (*p)() noexcept(1/X); // expected-error{{argument to noexcept specifier must be a constant expression}} expected-note{{division by zero}}
+ };
+
+ void g() {
+ A<0>::f(); // expected-note{{in instantiation of exception specification for 'f'}}
+ f<0>(); // expected-note{{in instantiation of function template specialization}}
+ }
}
diff --git a/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp b/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
index a376f0e5fd5..ae10399b9ad 100644
--- a/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
+++ b/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
@@ -137,3 +137,37 @@ namespace PR12763 {
};
void X::g() {} // expected-note {{in instantiation of}}
}
+
+namespace Variadic {
+ template<bool B> void check() { static_assert(B, ""); }
+ template<bool B, bool B2, bool ...Bs> void check() { static_assert(B, ""); check<B2, Bs...>(); }
+
+ template<typename ...T> void consume(T...);
+
+ template<typename ...T> void f(void (*...p)() throw (T)) {
+ void (*q[])() = { p... };
+ consume((p(),0)...);
+ }
+ template<bool ...B> void g(void (*...p)() noexcept (B)) {
+ consume((p(),0)...);
+ check<noexcept(p()) == B ...>();
+ }
+ template<typename ...T> void i() {
+ consume([]() throw(T) {} ...);
+ consume([]() noexcept(sizeof(T) == 4) {} ...);
+ }
+ template<bool ...B> void j() {
+ consume([](void (*p)() noexcept(B)) {
+ void (*q)() noexcept = p; // expected-error {{not superset of source}}
+ } ...);
+ }
+
+ void z() {
+ f<int, char, double>(nullptr, nullptr, nullptr);
+ g<true, false, true>(nullptr, nullptr, nullptr);
+ i<int, long, short>();
+ j<true, true>();
+ j<true, false>(); // expected-note {{in instantiation of}}
+ }
+
+}
diff --git a/clang/test/SemaTemplate/instantiate-exception-spec.cpp b/clang/test/SemaTemplate/instantiate-exception-spec.cpp
index 993ee8dfae1..d3411722283 100644
--- a/clang/test/SemaTemplate/instantiate-exception-spec.cpp
+++ b/clang/test/SemaTemplate/instantiate-exception-spec.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -verify %s -DERRORS
+// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -emit-llvm-only %s
+#ifdef ERRORS
template<typename T> void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}}
struct Incomplete; // expected-note{{forward}}
@@ -7,3 +9,20 @@ void test_f1(Incomplete *incomplete_p, int *int_p) {
f1(int_p);
f1(incomplete_p); // expected-note{{instantiation of}}
}
+#endif
+
+template<typename T> void f(void (*p)() throw(T)) {
+#ifdef ERRORS
+ void (*q)() throw(char) = p; // expected-error {{target exception spec}}
+
+ extern void (*p2)() throw(T);
+ void (*q2)() throw(char) = p2; // expected-error {{target exception spec}}
+
+ extern void (*p3)() throw(char);
+ void (*q3)() throw(T) = p3; // expected-error {{target exception spec}}
+
+ void (*q4)() throw(T) = p2; // ok
+#endif
+ p();
+}
+void g() { f<int>(0); } // expected-note {{instantiation of}}
OpenPOWER on IntegriCloud