X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcForeign.lhs;fp=compiler%2Ftypecheck%2FTcForeign.lhs;h=23756d97c351b99de50b5f66d827140595a3455d;hb=2da37f4f15790377900fa6c38ff8fdcd394dfaa2;hp=35f627e48d37aa597a053fd977b4a7c006ba3fa2;hpb=a4005d2d0c18ffa72ba7bd0fa052666e70e8c16e;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcForeign.lhs b/compiler/typecheck/TcForeign.lhs index 35f627e..23756d9 100644 --- a/compiler/typecheck/TcForeign.lhs +++ b/compiler/typecheck/TcForeign.lhs @@ -151,6 +151,16 @@ tcCheckFIType sig_ty arg_tys res_ty idecl@(CImport cconv safety _ _ (CFunction t checkForeignArgs (isFFIArgumentTy dflags safety) arg_tys checkForeignRes nonIOok (isFFIImportResultTy dflags) res_ty return idecl + | cconv == PrimCallConv = do + checkCg (checkCOrAsmOrDotNetOrInterp) + checkCTarget target + check (safety == PlayRisky) + (text "A `foreign import prim' must always be annotated as `unsafe'") + dflags <- getDOpts + checkForeignArgs (isFFIPrimArgumentTy dflags) arg_tys + -- prim import result is more liberal, allows (#,,#) + checkForeignRes nonIOok (isFFIPrimResultTy dflags) res_ty + return idecl | otherwise = do -- Normal foreign import checkCg (checkCOrAsmOrDotNetOrInterp) checkCConv cconv @@ -348,6 +358,7 @@ checkCConv StdCallConv = return () #else checkCConv StdCallConv = addErrTc (text "calling convention not supported on this platform: stdcall") #endif +checkCConv PrimCallConv = addErrTc (text "The `prim' calling convention can only be used with `foreign import'") checkCConv CmmCallConv = panic "checkCConv CmmCallConv" \end{code}