diff options
author | Torvald Riegel <triegel@redhat.com> | 2016-01-15 22:42:41 +0000 |
---|---|---|
committer | Torvald Riegel <torvald@gcc.gnu.org> | 2016-01-15 22:42:41 +0000 |
commit | a04d5fc95d7494824b07feb6c57cf71b4891e3de (patch) | |
tree | 2a0e76101e1e20d6aaa161901261dee89f905afb /libitm | |
parent | 40c43acacc1765416278e6636c20c5e3a78a7384 (diff) | |
download | gcc-a04d5fc95d7494824b07feb6c57cf71b4891e3de.tar.gz |
libstdc++: Make certain exceptions transaction_safe.
From-SVN: r232454
Diffstat (limited to 'libitm')
-rw-r--r-- | libitm/ChangeLog | 4 | ||||
-rw-r--r-- | libitm/testsuite/libitm.c++/libstdc++-safeexc.C | 89 |
2 files changed, 93 insertions, 0 deletions
diff --git a/libitm/ChangeLog b/libitm/ChangeLog index adcbf1d4f57..5026833da76 100644 --- a/libitm/ChangeLog +++ b/libitm/ChangeLog @@ -1,3 +1,7 @@ +2015-01-15 Torvald Riegel <triegel@redhat.com> + + testsuite/libitm.c++/libstdc++-safeexc.C: New. + 2016-01-13 Torvald Riegel <triegel@redhat.com> * beginend.cc (gtm_thread::trycommit): Fix seq_cst fences. diff --git a/libitm/testsuite/libitm.c++/libstdc++-safeexc.C b/libitm/testsuite/libitm.c++/libstdc++-safeexc.C new file mode 100644 index 00000000000..3e1655e83ec --- /dev/null +++ b/libitm/testsuite/libitm.c++/libstdc++-safeexc.C @@ -0,0 +1,89 @@ +// Tests that the exceptions declared by the TM TS (N4514) as transaction_safe +// are indeed that. Thus, this also tests the transactional clones in +// libstdc++ and libsupc++. + +// { dg-do run } + +#include <iostream> +#include <exception> +#include <stdexcept> +#include <string> + +using namespace std; + +template<typename T> void thrower(const T& t) +{ + try + { + atomic_commit + { + throw t; + } + } + catch (T ex) + { + if (ex != t) abort (); + } +} + +template<typename T> void thrower1(const string& what) +{ + try + { + atomic_commit + { + throw T (); + } + } + catch (T ex) + { + if (what != ex.what()) abort (); + } +} + +template<typename T> void thrower2(const string& what) +{ + try + { + atomic_commit + { + throw T (what); + } + } + catch (T ex) + { + if (what != ex.what()) abort (); + } +} + + +int main () +{ + thrower<unsigned int> (23); + thrower<int> (23); + thrower<unsigned short> (23); + thrower<short> (23); + thrower<unsigned char> (23); + thrower<char> (23); + thrower<unsigned long int> (42); + thrower<long int> (42); + thrower<unsigned long long int> (42); + thrower<long long int> (42); + thrower<double> (23.42); + thrower<long double> (23.42); + thrower<float> (23.42); + thrower<void*> (0); + thrower<void**> (0); + thrower1<exception> ("std::exception"); + thrower1<bad_exception> ("std::bad_exception"); + thrower2<logic_error> ("test"); + thrower2<domain_error> ("test"); + thrower2<invalid_argument> ("test"); + thrower2<length_error> ("test"); + thrower2<out_of_range> ("test"); + thrower2<runtime_error> ("test"); + thrower2<range_error> ("test"); + thrower2<overflow_error> ("test"); + thrower2<underflow_error> ("test"); + return 0; +} |