From 3847ae0ccf67bddf73304a39f5320c3ba285aa48 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Wed, 5 Aug 2020 21:16:06 -0400 Subject: testsuite: Add test for #18527 --- testsuite/tests/codeGen/should_run/T18527.hs | 20 ++++++++++++++++++++ testsuite/tests/codeGen/should_run/T18527.stdout | 3 +++ testsuite/tests/codeGen/should_run/T18527FFI.c | 14 ++++++++++++++ testsuite/tests/codeGen/should_run/all.T | 1 + 4 files changed, 38 insertions(+) create mode 100644 testsuite/tests/codeGen/should_run/T18527.hs create mode 100644 testsuite/tests/codeGen/should_run/T18527.stdout create mode 100644 testsuite/tests/codeGen/should_run/T18527FFI.c (limited to 'testsuite') 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 +#include + +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']) -- cgit v1.2.1