diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-10-16 23:00:46 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-10-16 23:00:46 +0000 |
commit | 9c04bce1f1b22feff652b40b0aab1d9ed278baf1 (patch) | |
tree | 823dea72315b07d4c27c6ede1631108c800e196a /clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp | |
parent | 82e3e373b3e0c4d8d47a60d3ee1f9b348d8cf413 (diff) | |
download | bcm5719-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-cxx11.cpp')
-rw-r--r-- | clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp | 41 |
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}} + } + +} |