summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2009-06-11 20:26:47 +0000
committerDuncan Coutts <duncan@well-typed.com>2009-06-11 20:26:47 +0000
commitf5c113de54455bc1320da4674c70e17598832533 (patch)
tree246ae5e990de58b94bcce4adb63f5b814117f924 /compiler
parent0efe9bd77f47f80cef7f10c435ea9efcda10d2b0 (diff)
downloadhaskell-f5c113de54455bc1320da4674c70e17598832533.tar.gz
Require GHCForeignImportPrim for "foreign import prim"
In practise currently you also need UnliftedFFITypes, however the restriction to just unlifted types may be lifted in future.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/main/DynFlags.hs2
-rw-r--r--compiler/typecheck/TcForeign.lhs4
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index d8b2e784a5..f4971cd7cd 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -203,6 +203,7 @@ data DynFlag
| Opt_ExtendedDefaultRules -- Use GHC's extended rules for defaulting
| Opt_ForeignFunctionInterface
| Opt_UnliftedFFITypes
+ | Opt_GHCForeignImportPrim
| Opt_PArr -- Syntactic support for parallel arrays
| Opt_Arrows -- Arrow-notation syntax
| Opt_TemplateHaskell
@@ -1759,6 +1760,7 @@ xFlags = [
( "TransformListComp", Opt_TransformListComp, const Supported ),
( "ForeignFunctionInterface", Opt_ForeignFunctionInterface, const Supported ),
( "UnliftedFFITypes", Opt_UnliftedFFITypes, const Supported ),
+ ( "GHCForeignImportPrim", Opt_GHCForeignImportPrim, const Supported ),
( "LiberalTypeSynonyms", Opt_LiberalTypeSynonyms, const Supported ),
( "Rank2Types", Opt_Rank2Types, const Supported ),
( "RankNTypes", Opt_RankNTypes, const Supported ),
diff --git a/compiler/typecheck/TcForeign.lhs b/compiler/typecheck/TcForeign.lhs
index 1a8a3f354c..52b1ec61f1 100644
--- a/compiler/typecheck/TcForeign.lhs
+++ b/compiler/typecheck/TcForeign.lhs
@@ -152,11 +152,13 @@ tcCheckFIType sig_ty arg_tys res_ty idecl@(CImport cconv safety _ _ (CFunction t
checkForeignRes nonIOok (isFFIImportResultTy dflags) res_ty
return idecl
| cconv == PrimCallConv = do
+ dflags <- getDOpts
+ check (dopt Opt_GHCForeignImportPrim dflags)
+ (text "Use -XGHCForeignImportPrim to allow `foreign import prim'.")
checkCg (checkCOrAsmOrDotNetOrInterp)
checkCTarget target
check (playSafe safety)
(text "The safe/unsafe annotation should not be used with `foreign import prim'.")
- dflags <- getDOpts
checkForeignArgs (isFFIPrimArgumentTy dflags) arg_tys
-- prim import result is more liberal, allows (#,,#)
checkForeignRes nonIOok (isFFIPrimResultTy dflags) res_ty