aboutsummaryrefslogtreecommitdiff
path: root/libitm
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-05 15:21:15 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-05 15:21:15 +0000
commit4965c5f9a75e6a32ffaf0ca7c7214bece9b7f69f (patch)
treebc23e58c8a9cd123b8a82acdc61a8498439f39f6 /libitm
parent558e6810f0a18b67eb8474bd86db23ab7de4f2fe (diff)
Move runtime transactional memory tests to libitm testsute.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228489 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libitm')
-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 00000000000..156121142e7
--- /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 00000000000..307a63924c3
--- /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 00000000000..68275e99706
--- /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();
+}