Commit f5c113de authored by Duncan Coutts's avatar Duncan Coutts

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.
parent 0efe9bd7
......@@ -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 ),
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment