From 4965c5f9a75e6a32ffaf0ca7c7214bece9b7f69f Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 5 Oct 2015 15:21:15 +0000 Subject: 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 --- libitm/testsuite/libitm.c++/eh-2.C | 10 ++++++++++ libitm/testsuite/libitm.c++/eh-3.C | 14 ++++++++++++++ libitm/testsuite/libitm.c++/eh-4.C | 21 +++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 libitm/testsuite/libitm.c++/eh-2.C create mode 100644 libitm/testsuite/libitm.c++/eh-3.C create mode 100644 libitm/testsuite/libitm.c++/eh-4.C (limited to 'libitm') 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(); +} -- cgit v1.2.1