Add testcase for #5664.
authorPaolo Capriotti <p.capriotti@gmail.com>
Tue, 3 Apr 2012 09:41:08 +0000 (10:41 +0100)
committerPaolo Capriotti <p.capriotti@gmail.com>
Wed, 4 Apr 2012 12:48:45 +0000 (13:48 +0100)
testsuite/tests/ffi/should_fail/T5664.hs [new file with mode: 0644]
testsuite/tests/ffi/should_fail/T5664.stderr [new file with mode: 0644]
testsuite/tests/ffi/should_fail/all.T

diff --git a/testsuite/tests/ffi/should_fail/T5664.hs b/testsuite/tests/ffi/should_fail/T5664.hs
new file mode 100644 (file)
index 0000000..4966f3a
--- /dev/null
@@ -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 (file)
index 0000000..30bd017
--- /dev/null
@@ -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))
index 188ef99..8da2702 100644 (file)
@@ -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'])