aboutsummaryrefslogtreecommitdiff
path: root/libitm/testsuite
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>2015-10-05 11:21:15 -0400
committerJason Merrill <jason@gcc.gnu.org>2015-10-05 11:21:15 -0400
commit66c69a82f4fcad5d43d25358e6bc35f066946940 (patch)
treebc23e58c8a9cd123b8a82acdc61a8498439f39f6 /libitm/testsuite
parent4314a3efd0738504350bc683d8f977ff2ac25ddf (diff)
downloadgcc-66c69a82f4fcad5d43d25358e6bc35f066946940.zip
gcc-66c69a82f4fcad5d43d25358e6bc35f066946940.tar.gz
gcc-66c69a82f4fcad5d43d25358e6bc35f066946940.tar.bz2
Move runtime transactional memory tests to libitm testsute.
From-SVN: r228489
Diffstat (limited to 'libitm/testsuite')
-rw-r--r--libitm/testsuite/libitm.c++/eh-2.C10
-rw-r--r--libitm/testsuite/libitm.c++/eh-3.C14
-rw-r--r--libitm/testsuite/libitm.c++/eh-4.C21
3 files changed, 45 insertions, 0 deletions
diff --git a/libitm/testsuite/libitm.c++/eh-2.C b/libitm/testsuite/libitm.c++/eh-2.C
new file mode 100644
index 0000000..1561211
--- /dev/null
+++ b/libitm/testsuite/libitm.c++/eh-2.C
@@ -0,0 +1,10 @@
+// A handler can involve a transaction-safety conversion.
+// { dg-do run }
+// { dg-options "-fgnu-tm" }
+
+void g() transaction_safe {}
+int main()
+{
+ try { throw g; }
+ catch (void (*p)()) { }
+}
diff --git a/libitm/testsuite/libitm.c++/eh-3.C b/libitm/testsuite/libitm.c++/eh-3.C
new file mode 100644
index 0000000..307a639
--- /dev/null
+++ b/libitm/testsuite/libitm.c++/eh-3.C
@@ -0,0 +1,14 @@
+// A handler cannot do the reverse of a transaction-safety conversion.
+// { dg-do run }
+// { dg-options "-fgnu-tm" }
+
+extern "C" void abort();
+
+void g() {}
+
+int main()
+{
+ try { throw g; }
+ catch (void (*p)() transaction_safe) { abort(); }
+ catch (...) { }
+}
diff --git a/libitm/testsuite/libitm.c++/eh-4.C b/libitm/testsuite/libitm.c++/eh-4.C
new file mode 100644
index 0000000..68275e9
--- /dev/null
+++ b/libitm/testsuite/libitm.c++/eh-4.C
@@ -0,0 +1,21 @@
+// Test that throwing out of an atomic_commit block commits the transaction.
+
+// { dg-do run }
+// { dg-options "-fgnu-tm" }
+
+int main()
+{
+ static int i;
+ bool caught = false;
+ try {
+ atomic_commit {
+ i = 12;
+ throw 42;
+ i = 24;
+ }
+ } catch (int x) {
+ caught = (x == 42);
+ }
+ if (!caught || i != 12)
+ __builtin_abort();
+}