summaryrefslogtreecommitdiff
path: root/testsuite/tests/ffi
diff options
context:
space:
mode:
authorPaolo Capriotti <p.capriotti@gmail.com>2012-04-03 10:41:08 +0100
committerPaolo Capriotti <p.capriotti@gmail.com>2012-04-04 13:48:45 +0100
commitd6ff372fac1392ca0c71d85a4ca6e978d628c04e (patch)
tree292c779683d009b23b3755456e7153fe59ebc2a5 /testsuite/tests/ffi
parent47c2cb0ce02f2202b1f04b2ef9ff9a3517faef94 (diff)
downloadhaskell-d6ff372fac1392ca0c71d85a4ca6e978d628c04e.tar.gz
Add testcase for #5664.
Diffstat (limited to 'testsuite/tests/ffi')
-rw-r--r--testsuite/tests/ffi/should_fail/T5664.hs25
-rw-r--r--testsuite/tests/ffi/should_fail/T5664.stderr13
-rw-r--r--testsuite/tests/ffi/should_fail/all.T1
3 files changed, 39 insertions, 0 deletions
diff --git a/testsuite/tests/ffi/should_fail/T5664.hs b/testsuite/tests/ffi/should_fail/T5664.hs
new file mode 100644
index 0000000000..4966f3abb9
--- /dev/null
+++ b/testsuite/tests/ffi/should_fail/T5664.hs
@@ -0,0 +1,25 @@
+module T5664 where
+
+import Foreign
+import Foreign.C
+
+data D = D
+newtype I = I CInt
+
+foreign import ccall "dynamic"
+ mkFun1 :: FunPtr (CInt -> IO ()) -> CInt -> IO ()
+
+foreign import ccall "dynamic"
+ mkFun2 :: FunPtr (I -> IO ()) -> CInt -> IO ()
+
+foreign import ccall "dynamic"
+ mkFun3 :: FunPtr (D -> IO ()) -> CInt -> IO ()
+
+foreign import ccall "wrapper"
+ mkCallBack1 :: IO CInt -> IO (FunPtr (IO CInt))
+
+foreign import ccall "wrapper"
+ mkCallBack2 :: IO CInt -> IO (FunPtr (IO I))
+
+foreign import ccall "wrapper"
+ mkCallBack3 :: IO CInt -> IO (FunPtr (IO D))
diff --git a/testsuite/tests/ffi/should_fail/T5664.stderr b/testsuite/tests/ffi/should_fail/T5664.stderr
new file mode 100644
index 0000000000..30bd017a1d
--- /dev/null
+++ b/testsuite/tests/ffi/should_fail/T5664.stderr
@@ -0,0 +1,13 @@
+
+T5664.hs:15:1:
+ Unacceptable argument type in foreign declaration:
+ FunPtr (D -> IO ())
+ When checking declaration:
+ foreign import ccall safe "dynamic" mkFun3
+ :: FunPtr (D -> IO ()) -> CInt -> IO ()
+
+T5664.hs:24:1:
+ Unacceptable result type in foreign declaration: IO (FunPtr (IO D))
+ When checking declaration:
+ foreign import ccall safe "wrapper" mkCallBack3
+ :: IO CInt -> IO (FunPtr (IO D))
diff --git a/testsuite/tests/ffi/should_fail/all.T b/testsuite/tests/ffi/should_fail/all.T
index 188ef99bfb..8da27021d8 100644
--- a/testsuite/tests/ffi/should_fail/all.T
+++ b/testsuite/tests/ffi/should_fail/all.T
@@ -10,3 +10,4 @@ test('ccfail004', only_compiler_types(['ghc']), multimod_compile_fail, ['ccfail0
test('ccfail005', only_compiler_types(['ghc']), compile_fail, [''])
test('ccall_value', normal, compile_fail, [''])
test('capi_value_function', normal, compile_fail, [''])
+test('T5664', normal, compile_fail, ['-v0'])