diff options
-rw-r--r-- | testsuite/tests/rts/T11829.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/rts/T11829.stderr | 1 | ||||
-rw-r--r-- | testsuite/tests/rts/T11829.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/rts/T11829_c.cpp | 19 | ||||
-rw-r--r-- | testsuite/tests/rts/all.T | 5 |
5 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/rts/T11829.hs b/testsuite/tests/rts/T11829.hs new file mode 100644 index 0000000000..5983dfb226 --- /dev/null +++ b/testsuite/tests/rts/T11829.hs @@ -0,0 +1,5 @@ +module Main where +import Foreign.C.Types +foreign import ccall func :: IO CInt +main :: IO () +main = print =<< func diff --git a/testsuite/tests/rts/T11829.stderr b/testsuite/tests/rts/T11829.stderr new file mode 100644 index 0000000000..0527e6bd2d --- /dev/null +++ b/testsuite/tests/rts/T11829.stderr @@ -0,0 +1 @@ +This is a test diff --git a/testsuite/tests/rts/T11829.stdout b/testsuite/tests/rts/T11829.stdout new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/testsuite/tests/rts/T11829.stdout @@ -0,0 +1 @@ +42 diff --git a/testsuite/tests/rts/T11829_c.cpp b/testsuite/tests/rts/T11829_c.cpp new file mode 100644 index 0000000000..959851ad74 --- /dev/null +++ b/testsuite/tests/rts/T11829_c.cpp @@ -0,0 +1,19 @@ +#include <iostream> +#include <exception> +extern "C" { + +int func() { + try { + throw std::runtime_error("This is a test"); + } catch(const std::runtime_error &c) { + std::cerr << c.what() << std::endl; + return 42; + } catch(...) { + std::cerr << "Catch-all must not fire!" << std::endl; + return -1; + } + std::cerr << "Control must not reach past try-catch block!" << std::endl; + return -2; +} + +} diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T index 7adb936b08..f2098f4122 100644 --- a/testsuite/tests/rts/all.T +++ b/testsuite/tests/rts/all.T @@ -470,6 +470,11 @@ test('keep-cafs', ], makefile_test, ['KeepCafs']) +# Test proper functioning of C++ exceptions within a C++ program. +# On darwin, this requires -fcompact-unwind. +# When -fcompact-unwind becomes default, generalize test to all platforms. +test('T11829', unless(opsys('darwin'), skip), compile_and_run, ['T11829_c.cpp -lstdc++ -fcompact-unwind']) + test('T16514', unless(opsys('mingw32'), skip), compile_and_run, ['T16514_c.cpp -lstdc++']) test('test-zeroongc', extra_run_opts('-DZ'), compile_and_run, ['-debug']) |