diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-06-22 18:07:31 -0400 |
---|---|---|
committer | Zubin Duggal <zubin.duggal@gmail.com> | 2022-07-14 14:39:37 +0530 |
commit | c48d7704cc433107c65431d27b0fe6da1fb1161d (patch) | |
tree | c9e62d90fd789d5270d24e2e99b4fd8a65c4f793 | |
parent | 85aa822901b0d1b50c95fd25261da2e4aa0e8e41 (diff) | |
download | haskell-c48d7704cc433107c65431d27b0fe6da1fb1161d.tar.gz |
testsuite: Add test for #20735
(cherry picked from commit c006ac0d1454119f0b456a00ff2416831c955e99)
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', '')], '']) + |