aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2015-03-17 14:24:55 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2015-03-17 14:24:55 +0000
commit95f2fd9c5dd0664765fe51f908129d5341c9d552 (patch)
tree351dfbcaab8d263bdf886a5fa3a386894c291861 /libstdc++-v3
parent076d86f3d2c8df6678b65fca53e1910e3a6c87bc (diff)
downloadgcc-95f2fd9c5dd0664765fe51f908129d5341c9d552.zip
gcc-95f2fd9c5dd0664765fe51f908129d5341c9d552.tar.gz
gcc-95f2fd9c5dd0664765fe51f908129d5341c9d552.tar.bz2
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
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/libsupc++/nested_exception.h2
-rw-r--r--libstdc++-v3/testsuite/18_support/nested_exception/throw_with_nested.cc22
3 files changed, 30 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index efba7a4..ce12e81 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2015-03-17 Jonathan Wakely <jwakely@redhat.com>
+
+ * 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 <jwakely@redhat.com>
* 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 7f7e14e..a716f75 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<typename _Tp, bool = __is_class(_Tp)>
+ template<typename _Tp, bool = __is_class(_Tp) && !__is_final(_Tp)>
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 f1a0e9a..7ebf3b7 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;
}