aboutsummaryrefslogtreecommitdiff
path: root/libitm
diff options
context:
space:
mode:
authortorvald <torvald@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-15 22:42:41 +0000
committertorvald <torvald@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-15 22:42:41 +0000
commit13143e139230dc4d72710a6c4c312105aeddce4f (patch)
tree2a0e76101e1e20d6aaa161901261dee89f905afb /libitm
parente390c57d60cfee5ff4889489a6afaf4bda7cb32c (diff)
libstdc++: Make certain exceptions transaction_safe.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232454 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libitm')
-rw-r--r--libitm/ChangeLog4
-rw-r--r--libitm/testsuite/libitm.c++/libstdc++-safeexc.C89
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;
+}