summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate/instantiate-exception-spec.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-10-16 23:00:46 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-10-16 23:00:46 +0000
commit9c04bce1f1b22feff652b40b0aab1d9ed278baf1 (patch)
tree823dea72315b07d4c27c6ede1631108c800e196a /clang/test/SemaTemplate/instantiate-exception-spec.cpp
parent82e3e373b3e0c4d8d47a60d3ee1f9b348d8cf413 (diff)
downloadbcm5719-llvm-9c04bce1f1b22feff652b40b0aab1d9ed278baf1.tar.gz
bcm5719-llvm-9c04bce1f1b22feff652b40b0aab1d9ed278baf1.zip
Re-commit r217995 and follow-up patches (r217997, r218011, r218053). These were
reverted in r218058 because they triggered a rejects-valid bug in MSVC. Original commit message from r217995: Instantiate exception specifications when instantiating function types (other than the type of a function declaration). We previously didn't instantiate these at all! This also covers the pathological case where the only mention of a parameter pack is within the exception specification; this gives us a second way (other than alias templates) to reach the horrible state where a type contains an unexpanded pack, but its canonical type does not. llvm-svn: 219977
Diffstat (limited to 'clang/test/SemaTemplate/instantiate-exception-spec.cpp')
-rw-r--r--clang/test/SemaTemplate/instantiate-exception-spec.cpp21
1 files changed, 20 insertions, 1 deletions
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