summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2022-03-15 15:44:41 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-03-17 10:16:37 -0400
commit0f0e2394942842c700484ecf4b473a929a436b0d (patch)
tree612ac885aeacea48d09678c637bc18f8c6180729 /testsuite/tests/rts
parentbb779b90bb093274ccf7a8e5b19f6661f4925bde (diff)
downloadhaskell-0f0e2394942842c700484ecf4b473a929a436b0d.tar.gz
linker: Initial Windows C++ exception unwinding support
Diffstat (limited to 'testsuite/tests/rts')
-rw-r--r--testsuite/tests/rts/linker/Makefile5
-rw-r--r--testsuite/tests/rts/linker/T20918.hs17
-rw-r--r--testsuite/tests/rts/linker/T20918.stdout5
-rw-r--r--testsuite/tests/rts/linker/T20918_v.cc19
-rw-r--r--testsuite/tests/rts/linker/all.T8
5 files changed, 54 insertions, 0 deletions
diff --git a/testsuite/tests/rts/linker/Makefile b/testsuite/tests/rts/linker/Makefile
index eac2b90b07..35e0c2765c 100644
--- a/testsuite/tests/rts/linker/Makefile
+++ b/testsuite/tests/rts/linker/Makefile
@@ -119,3 +119,8 @@ T7072:
"$(TEST_HC)" -c T7072-main.c -o T7072-main.o
"$(TEST_HC)" T7072-main.c -o T7072-main -no-hs-main -debug
./T7072-main T7072-obj.o
+
+.PHONY: T20918
+T20918:
+ "$(TEST_CC)" -c T20918_v.cc -o T20918_v.o
+ echo hello | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) T20918_v.o T20918.hs -lstdc++
diff --git a/testsuite/tests/rts/linker/T20918.hs b/testsuite/tests/rts/linker/T20918.hs
new file mode 100644
index 0000000000..7a50c691e5
--- /dev/null
+++ b/testsuite/tests/rts/linker/T20918.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+
+module ThrowTest where
+
+import Foreign.C.Types
+import Data.Int()
+
+foreign import ccall "test_error_throwing.h equivalent_to_id"
+ equivalentToId :: CDouble -> IO CDouble
+
+hello :: IO ()
+hello = do
+ print "Hi"
+ shouldBe88 <- equivalentToId 88
+ print $ show shouldBe88
+ print "Bye"
+
diff --git a/testsuite/tests/rts/linker/T20918.stdout b/testsuite/tests/rts/linker/T20918.stdout
new file mode 100644
index 0000000000..5d1f019d13
--- /dev/null
+++ b/testsuite/tests/rts/linker/T20918.stdout
@@ -0,0 +1,5 @@
+"Hi"
+equivalent_to_id test-throw 1
+equivalent_to_id test-throw caught 20
+"88.0"
+"Bye"
diff --git a/testsuite/tests/rts/linker/T20918_v.cc b/testsuite/tests/rts/linker/T20918_v.cc
new file mode 100644
index 0000000000..39760deb75
--- /dev/null
+++ b/testsuite/tests/rts/linker/T20918_v.cc
@@ -0,0 +1,19 @@
+#include <stdlib.h>
+#include <string>
+#include <iostream>
+
+extern "C"
+{
+
+ double equivalent_to_id(double my_double)
+ {
+ try {
+ std::cout << "equivalent_to_id test-throw 1" << std::endl;
+ throw 20;
+ } catch(int my_error)
+ {
+ std::cout << "equivalent_to_id test-throw caught " << my_error << std::endl;
+ }
+ return my_double;
+ }
+}
diff --git a/testsuite/tests/rts/linker/all.T b/testsuite/tests/rts/linker/all.T
index 8e70ee8646..5191c4b0aa 100644
--- a/testsuite/tests/rts/linker/all.T
+++ b/testsuite/tests/rts/linker/all.T
@@ -119,3 +119,11 @@ test('T7072',
unless(opsys('linux'), skip),
req_rts_linker],
makefile_test, ['T7072'])
+
+
+test('T20918',
+ [extra_files(['T20918_v.cc']),
+ unless(opsys('mingw32'), skip),
+ req_rts_linker],
+ makefile_test, ['T20918'])
+