summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2011-09-30 20:23:04 +0100
committerIan Lynagh <igloo@earth.li>2011-09-30 23:52:55 +0100
commit8a051fca8085fb40543f0aa62f631ab8fd9d33f0 (patch)
tree8fdd0b9a60e913cf2759b04b59673235e30c43ea /testsuite
parent9d11154316ce4185cb4df81b85c1cb622de02cbc (diff)
downloadhaskell-8a051fca8085fb40543f0aa62f631ab8fd9d33f0.tar.gz
Add a test for newtypes and the FFI
You can only use newtypes in the FFI if the constructor is visible
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/ffi/should_fail/Ccfail004A.hs7
-rw-r--r--testsuite/tests/ffi/should_fail/all.T1
-rw-r--r--testsuite/tests/ffi/should_fail/ccfail004.hs10
-rw-r--r--testsuite/tests/ffi/should_fail/ccfail004.stderr16
4 files changed, 34 insertions, 0 deletions
diff --git a/testsuite/tests/ffi/should_fail/Ccfail004A.hs b/testsuite/tests/ffi/should_fail/Ccfail004A.hs
new file mode 100644
index 0000000000..106c2727b9
--- /dev/null
+++ b/testsuite/tests/ffi/should_fail/Ccfail004A.hs
@@ -0,0 +1,7 @@
+
+module Ccfail004A (NInt, NIO) where
+
+newtype NInt = NInt Int
+
+newtype NIO a = NIO (IO a)
+
diff --git a/testsuite/tests/ffi/should_fail/all.T b/testsuite/tests/ffi/should_fail/all.T
index bc6ee95e62..4793379fb4 100644
--- a/testsuite/tests/ffi/should_fail/all.T
+++ b/testsuite/tests/ffi/should_fail/all.T
@@ -6,3 +6,4 @@ test('ccfail001', only_compiler_types(['ghc']), compile_fail, [''])
test('ccfail002', only_compiler_types(['ghc']), compile_fail, [''])
test('ccfail003', only_compiler_types(['ghc']), compile_fail, [''])
test('T3066', only_compiler_types(['ghc']), compile_fail, [''])
+test('ccfail004', only_compiler_types(['ghc']), multimod_compile_fail, ['ccfail004', '-v0'])
diff --git a/testsuite/tests/ffi/should_fail/ccfail004.hs b/testsuite/tests/ffi/should_fail/ccfail004.hs
new file mode 100644
index 0000000000..5676d7c324
--- /dev/null
+++ b/testsuite/tests/ffi/should_fail/ccfail004.hs
@@ -0,0 +1,10 @@
+
+module Ccfail004 where
+
+import Ccfail004A
+
+-- Both these should be rejected as the NInt constructor isn't in scope
+foreign import ccall f1 :: NInt -> IO Int
+foreign import ccall f2 :: Int -> IO NInt
+foreign import ccall f3 :: Int -> NIO Int
+
diff --git a/testsuite/tests/ffi/should_fail/ccfail004.stderr b/testsuite/tests/ffi/should_fail/ccfail004.stderr
new file mode 100644
index 0000000000..08e3f4fdb5
--- /dev/null
+++ b/testsuite/tests/ffi/should_fail/ccfail004.stderr
@@ -0,0 +1,16 @@
+
+ccfail004.hs:7:1:
+ Unacceptable argument type in foreign declaration: NInt
+ When checking declaration:
+ foreign import ccall safe "static f1" f1 :: NInt -> IO Int
+
+ccfail004.hs:8:1:
+ Unacceptable result type in foreign declaration: IO NInt
+ When checking declaration:
+ foreign import ccall safe "static f2" f2 :: Int -> IO NInt
+
+ccfail004.hs:9:1:
+ Unacceptable result type in foreign declaration: NIO Int
+ When checking declaration:
+ foreign import ccall safe "static f3" f3 :: Int -> NIO Int
+