diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2019-01-15 13:14:45 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-01-20 21:35:20 -0500 |
commit | f035504b573b9684d53a6d035f8726672c1b0190 (patch) | |
tree | 5cc4037684d8967aa7b4808130cd9514d90a4501 /testsuite | |
parent | 6e7aa5e937b18a45ee39c8c67b7a2f7350b89a66 (diff) | |
download | haskell-f035504b573b9684d53a6d035f8726672c1b0190.tar.gz |
Add support for ASM foreign files (.s) in TH (#16180)
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/th/T16180.hs | 25 | ||||
-rw-r--r-- | testsuite/tests/th/T16180.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/th/all.T | 1 |
3 files changed, 28 insertions, 0 deletions
diff --git a/testsuite/tests/th/T16180.hs b/testsuite/tests/th/T16180.hs new file mode 100644 index 0000000000..2a4b80c976 --- /dev/null +++ b/testsuite/tests/th/T16180.hs @@ -0,0 +1,25 @@ +{-# LANGUAGE TemplateHaskell #-} + +module Main where + +import Language.Haskell.TH.Syntax +import Foreign.C.String + +$(do + -- some architectures require a "_" symbol prefix... + -- GHC defines a LEADING_UNDERSCORE CPP constant to indicate this. + addForeignSource LangAsm + "#if defined(LEADING_UNDERSCORE)\n\ + \.global \"_mydata\"\n\ + \_mydata:\n\ + \#else\n\ + \.global \"mydata\"\n\ + \mydata:\n\ + \#endif\n\ + \.ascii \"Hello world\\0\"\n" + return []) + +foreign import ccall "&mydata" mystring :: CString + +main :: IO () +main = putStrLn =<< peekCString mystring diff --git a/testsuite/tests/th/T16180.stdout b/testsuite/tests/th/T16180.stdout new file mode 100644 index 0000000000..a378710ebf --- /dev/null +++ b/testsuite/tests/th/T16180.stdout @@ -0,0 +1,2 @@ +Hello world + diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index 6783bb6c78..9ddf28345e 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -467,3 +467,4 @@ test('T15437', expect_broken(15437), multimod_compile, test('T15985', normal, compile, ['']) test('T16133', normal, compile_fail, ['']) test('T15471', normal, multimod_compile, ['T15471.hs', '-v0']) +test('T16180', normal, compile_and_run, ['']) |