summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-08-05 21:16:06 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-08-07 08:35:21 -0400
commit3847ae0ccf67bddf73304a39f5320c3ba285aa48 (patch)
tree857891d8859a51525cf82d8b83e03e6296f6e146 /testsuite
parent15b36de030ecdd60897bc7a6a02bdeabd0825be4 (diff)
downloadhaskell-3847ae0ccf67bddf73304a39f5320c3ba285aa48.tar.gz
testsuite: Add test for #18527
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/codeGen/should_run/T18527.hs20
-rw-r--r--testsuite/tests/codeGen/should_run/T18527.stdout3
-rw-r--r--testsuite/tests/codeGen/should_run/T18527FFI.c14
-rw-r--r--testsuite/tests/codeGen/should_run/all.T1
4 files changed, 38 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/T18527.hs b/testsuite/tests/codeGen/should_run/T18527.hs
new file mode 100644
index 0000000000..3205981960
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T18527.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+
+module Main where
+
+import Data.Bits (setBit)
+import Data.Word (Word32)
+import Data.Int (Int64)
+
+main :: IO ()
+main = offending 100 0 1
+
+offending :: Int64 -> Int64 -> Word32 -> IO ()
+offending h i id = do
+ oldMask <- sendMessage h (2245) i 0
+ let newMask = setBit oldMask (fromIntegral id)
+ sendMessage h (2244) i newMask
+ return ()
+
+foreign import ccall "func"
+ sendMessage :: Int64 -> Word32 -> Int64 -> Int64 -> IO Int64
diff --git a/testsuite/tests/codeGen/should_run/T18527.stdout b/testsuite/tests/codeGen/should_run/T18527.stdout
new file mode 100644
index 0000000000..651155af6c
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T18527.stdout
@@ -0,0 +1,3 @@
+ffi call
+ffi call
+
diff --git a/testsuite/tests/codeGen/should_run/T18527FFI.c b/testsuite/tests/codeGen/should_run/T18527FFI.c
new file mode 100644
index 0000000000..77f13ecef5
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T18527FFI.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <stdint.h>
+
+int64_t func(int64_t a, uint32_t b, int64_t c, int64_t d) {
+ printf("ffi call");
+ if (a == 1) {
+ printf(" with corrupted convention\n");
+ }
+ else {
+ printf("\n");
+ }
+ return 0;
+}
+
diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T
index bfe8c5b0d2..8892b506e4 100644
--- a/testsuite/tests/codeGen/should_run/all.T
+++ b/testsuite/tests/codeGen/should_run/all.T
@@ -207,3 +207,4 @@ test('T16449_2', exit_code(0), compile_and_run, [''])
test('T16846', [only_ways(['optasm']), exit_code(1)], compile_and_run, [''])
test('T17920', cmm_src, compile_and_run, [''])
+test('T18527', normal, compile_and_run, ['T18527FFI.c'])