From: Jonathan Wakely Date: Tue, 17 Mar 2015 14:24:55 +0000 (+0000) Subject: nested_exception.h: Do not try to derive from final classes. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=95f2fd9c5dd0664765fe51f908129d5341c9d552;p=gcc.git nested_exception.h: Do not try to derive from final classes. * libsupc++/nested_exception.h: Do not try to derive from final classes. * testsuite/18_support/nested_exception/throw_with_nested.cc: Test final class. From-SVN: r221476 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index efba7a417fc..ce12e81ab5f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2015-03-17 Jonathan Wakely + + * libsupc++/nested_exception.h: Do not try to derive from final + classes. + * testsuite/18_support/nested_exception/throw_with_nested.cc: Test + final class. + 2015-03-13 Jonathan Wakely * acinclude.m4: Make --enable-libstdcxx-time=auto work for dragonfly. diff --git a/libstdc++-v3/libsupc++/nested_exception.h b/libstdc++-v3/libsupc++/nested_exception.h index 7f7e14e32f6..a716f75adf4 100644 --- a/libstdc++-v3/libsupc++/nested_exception.h +++ b/libstdc++-v3/libsupc++/nested_exception.h @@ -108,7 +108,7 @@ namespace std { throw static_cast<_Up&&>(__t); } }; - template + template struct _Throw_with_nested_helper : _Throw_with_nested_impl<_Tp> { }; diff --git a/libstdc++-v3/testsuite/18_support/nested_exception/throw_with_nested.cc b/libstdc++-v3/testsuite/18_support/nested_exception/throw_with_nested.cc index f1a0e9a20f4..7ebf3b774e6 100644 --- a/libstdc++-v3/testsuite/18_support/nested_exception/throw_with_nested.cc +++ b/libstdc++-v3/testsuite/18_support/nested_exception/throw_with_nested.cc @@ -26,6 +26,8 @@ struct derived : std::nested_exception { }; struct not_derived { virtual ~not_derived() noexcept; }; inline not_derived::~not_derived() noexcept = default; +struct uninheritable final { }; + void test01() { bool test __attribute__((unused)) = false; @@ -72,9 +74,29 @@ void test02() VERIFY( test ); } +void test03() +{ + bool test __attribute__((unused)) = false; + + try + { + std::throw_with_nested(uninheritable()); + } + catch (const std::nested_exception&) + { + VERIFY( false ); + } + catch(const uninheritable&) + { + test = true; + } + VERIFY( test ); +} + int main() { test01(); test02(); + test03(); return 0; }