summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-11-12 02:00:47 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-11-12 02:00:47 +0000
commit2e32155b58aecf4ff9643b3bcae7a7f86d228b0a (patch)
tree523d1b31fda9a6d6be16b4d2f7161c036c54a116 /clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
parent68caa7d34d8a22330880d628029c6f129d3088bb (diff)
downloadbcm5719-llvm-2e32155b58aecf4ff9643b3bcae7a7f86d228b0a.tar.gz
bcm5719-llvm-2e32155b58aecf4ff9643b3bcae7a7f86d228b0a.zip
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. This is a re-commit of r219977: r219977 was reverted in r220038 because it hit a wrong-code bug in GCC 4.7.2. (That's gcc.gnu.org/PR56135, and affects any implicit lambda-capture of 'this' within a template.) r219977 was a re-commit of r217995, r218011, and r218053: r217995 was reverted in r218058 because it hit a rejects-valid bug in MSVC. (Incorrect overload resolution in the presence of using-declarations.) It was re-committed in r219977 with a workaround for the MSVC rejects-valid. r218011 was a workaround for an MSVC parser bug. (Incorrect desugaring of unbraced range-based for loop). llvm-svn: 221750
Diffstat (limited to 'clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp')
-rw-r--r--clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp b/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
index a376f0e5fd5..f62ef61758a 100644
--- a/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
+++ b/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
@@ -58,6 +58,13 @@ namespace dr1330_example {
S().f<S>(); // ok
S().f<int>(); // expected-note {{instantiation of exception spec}}
}
+
+ template<typename T>
+ struct U {
+ void f() noexcept(T::error);
+ void (g)() noexcept(T::error);
+ };
+ U<int> uint; // ok
}
namespace core_19754_example {
@@ -137,3 +144,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}}
+ }
+
+}
OpenPOWER on IntegriCloud