summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testsuite/tests/codeGen/should_run/T20735/T20735.hs19
-rw-r--r--testsuite/tests/codeGen/should_run/T20735/T20735.stdout8
-rw-r--r--testsuite/tests/codeGen/should_run/T20735/T20735_c.c32
-rw-r--r--testsuite/tests/codeGen/should_run/T20735/all.T5
4 files changed, 64 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/T20735/T20735.hs b/testsuite/tests/codeGen/should_run/T20735/T20735.hs
new file mode 100644
index 0000000000..6d691bd41f
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20735/T20735.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+
+module Main (main) where
+
+import Data.Int
+import System.IO
+
+foreign import ccall "func64" func64 :: Int64 -> IO Int64
+foreign import ccall "func32" func32 :: Int32 -> IO Int32
+foreign import ccall "func16" func16 :: Int16 -> IO Int16
+foreign import ccall "func8" func8 :: Int8 -> IO Int8
+
+main :: IO ()
+main = do
+ func64 (-2) >>= print >> hFlush stdout
+ func32 (-2) >>= print >> hFlush stdout
+ func16 (-2) >>= print >> hFlush stdout
+ func8 (-2) >>= print >> hFlush stdout
+
diff --git a/testsuite/tests/codeGen/should_run/T20735/T20735.stdout b/testsuite/tests/codeGen/should_run/T20735/T20735.stdout
new file mode 100644
index 0000000000..218272cb82
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20735/T20735.stdout
@@ -0,0 +1,8 @@
+-2
+-1
+-2
+-1
+-2
+-1
+-2
+-1
diff --git a/testsuite/tests/codeGen/should_run/T20735/T20735_c.c b/testsuite/tests/codeGen/should_run/T20735/T20735_c.c
new file mode 100644
index 0000000000..890d09199a
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20735/T20735_c.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <stdint.h>
+
+
+int64_t func64(int64_t targetType)
+{
+ printf("%d\n", (int)targetType);
+ fflush(stdout);
+ return (-1);
+}
+
+int32_t func32(int32_t targetType)
+{
+ printf("%d\n", (int)targetType);
+ fflush(stdout);
+ return (-1);
+}
+
+int16_t func16(int16_t targetType)
+{
+ printf("%d\n", (int)targetType);
+ fflush(stdout);
+ return (-1);
+}
+
+int8_t func8(int8_t targetType)
+{
+ printf("%d\n", (int)targetType);
+ fflush(stdout);
+ return (-1);
+}
+
diff --git a/testsuite/tests/codeGen/should_run/T20735/all.T b/testsuite/tests/codeGen/should_run/T20735/all.T
new file mode 100644
index 0000000000..d10c0c0f79
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20735/all.T
@@ -0,0 +1,5 @@
+test('T20735',
+ normal,
+ multi_compile_and_run,
+ ['T20735', [('T20735_c.c', '')], ''])
+