Skip to content
Snippets Groups Projects
Commit 2133ab18 authored by Robert Hensing's avatar Robert Hensing
Browse files

Add test case for C++ exception handling

parent 1496a2a7
No related branches found
No related tags found
No related merge requests found
module Main where
import Foreign.C.Types
foreign import ccall func :: IO CInt
main :: IO ()
main = print =<< func
This is a test
42
#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;
}
}
......@@ -417,6 +417,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'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment