summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghci/prog014
diff options
context:
space:
mode:
authorSylvain HENRY <hsyl20@gmail.com>2015-11-11 12:32:08 +0100
committerBen Gamari <ben@smart-cactus.org>2015-11-11 12:32:16 +0100
commitbadf5d54907a5a5e9224c44310f991a52379b4c1 (patch)
tree94f4b585569ba424a1b6733797262325b3ab8bdc /testsuite/tests/ghci/prog014
parent0f49508399a1fc145e17950ea1591da7f0de4f2a (diff)
downloadhaskell-badf5d54907a5a5e9224c44310f991a52379b4c1.tar.gz
Detect invalid foreign imports in bytecode compiler
The bytecode compiler doesn't handle every foreign import calling convention. Instead of crashing during the generation of the foreign call, we display an error. Fix lint warnings Test Plan: prog014 ghci test added Reviewers: austin, hvr, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1458 GHC Trac Issues: #10462
Diffstat (limited to 'testsuite/tests/ghci/prog014')
-rw-r--r--testsuite/tests/ghci/prog014/Makefile11
-rw-r--r--testsuite/tests/ghci/prog014/Primop.hs10
-rw-r--r--testsuite/tests/ghci/prog014/dummy.c5
-rw-r--r--testsuite/tests/ghci/prog014/prog014.T8
-rw-r--r--testsuite/tests/ghci/prog014/prog014.script2
-rw-r--r--testsuite/tests/ghci/prog014/prog014.stderr2
-rw-r--r--testsuite/tests/ghci/prog014/prog014.stdout0
7 files changed, 38 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/prog014/Makefile b/testsuite/tests/ghci/prog014/Makefile
new file mode 100644
index 0000000000..e053c15b63
--- /dev/null
+++ b/testsuite/tests/ghci/prog014/Makefile
@@ -0,0 +1,11 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+clean:
+ rm -f *.o *.hi
+
+prog014: clean
+ '$(TEST_HC)' $(TEST_HC_OPTS) -c dummy.c
+
+.PHONY: clean prog014
diff --git a/testsuite/tests/ghci/prog014/Primop.hs b/testsuite/tests/ghci/prog014/Primop.hs
new file mode 100644
index 0000000000..40c1ade3ee
--- /dev/null
+++ b/testsuite/tests/ghci/prog014/Primop.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE GHCForeignImportPrim, MagicHash,
+ UnliftedFFITypes, UnboxedTuples #-}
+
+import GHC.Exts
+
+foreign import prim "dummy"
+ dummy :: Word# -> Word#
+
+foreign import prim "dummy2"
+ dummy2 :: Any -> State# RealWorld -> (# State# RealWorld, Word# #)
diff --git a/testsuite/tests/ghci/prog014/dummy.c b/testsuite/tests/ghci/prog014/dummy.c
new file mode 100644
index 0000000000..b118cc8ee0
--- /dev/null
+++ b/testsuite/tests/ghci/prog014/dummy.c
@@ -0,0 +1,5 @@
+void dummy() {
+}
+
+void dummy2() {
+}
diff --git a/testsuite/tests/ghci/prog014/prog014.T b/testsuite/tests/ghci/prog014/prog014.T
new file mode 100644
index 0000000000..506c8b76e1
--- /dev/null
+++ b/testsuite/tests/ghci/prog014/prog014.T
@@ -0,0 +1,8 @@
+test('prog014',
+ [ extra_run_opts('dummy.o')
+ , pre_cmd('$MAKE -s --no-print-directory prog014')
+ , clean_cmd('rm -f dummy.o')
+ ],
+ ghci_script,
+ ['prog014.script'])
+
diff --git a/testsuite/tests/ghci/prog014/prog014.script b/testsuite/tests/ghci/prog014/prog014.script
new file mode 100644
index 0000000000..0c8d96ef99
--- /dev/null
+++ b/testsuite/tests/ghci/prog014/prog014.script
@@ -0,0 +1,2 @@
+:set editor echo
+:l Primop.hs
diff --git a/testsuite/tests/ghci/prog014/prog014.stderr b/testsuite/tests/ghci/prog014/prog014.stderr
new file mode 100644
index 0000000000..6d7b7fba37
--- /dev/null
+++ b/testsuite/tests/ghci/prog014/prog014.stderr
@@ -0,0 +1,2 @@
+Error: bytecode compiler can't handle some foreign calling conventions
+ Workaround: use -fobject-code, or compile this module to .o separately.
diff --git a/testsuite/tests/ghci/prog014/prog014.stdout b/testsuite/tests/ghci/prog014/prog014.stdout
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/ghci/prog014/prog014.stdout