Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Shayne Fletcher
Glasgow Haskell Compiler
Commits
942939c0
Commit
942939c0
authored
Dec 19, 2012
by
Simon Peyton Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Trac #7506 (missing check for form of FFI type)
parent
650f76fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
compiler/typecheck/TcForeign.lhs
compiler/typecheck/TcForeign.lhs
+8
-4
No files found.
compiler/typecheck/TcForeign.lhs
View file @
942939c0
...
...
@@ -47,7 +47,6 @@ import Platform
import SrcLoc
import Bag
import FastString
import Util
import Control.Monad
\end{code}
...
...
@@ -213,11 +212,11 @@ tcFImport d = pprPanic "tcFImport" (ppr d)
tcCheckFIType :: Type -> [Type] -> Type -> ForeignImport -> TcM ForeignImport
tcCheckFIType sig_ty arg_tys res_ty (CImport cconv safety mh l@(CLabel _))
= ASSERT( null arg_tys )
do checkCg checkCOrAsmOrLlvmOrInterp
-- Foreign import label
=
do checkCg checkCOrAsmOrLlvmOrInterp
-- NB check res_ty not sig_ty!
-- In case sig_ty is (forall a. ForeignPtr a)
check (isFFILabelTy res_ty) (illegalForeign
TyErr empty
sig_ty)
check (
null arg_tys &&
isFFILabelTy res_ty) (illegalForeign
LabelErr
sig_ty)
cconv' <- checkCConv cconv
return (CImport cconv' safety mh l)
...
...
@@ -483,6 +482,11 @@ check :: Bool -> MsgDoc -> TcM ()
check True _ = return ()
check _ the_err = addErrTc the_err
illegalForeignLabelErr :: Type -> SDoc
illegalForeignLabelErr ty
= vcat [ illegalForeignTyErr empty ty
, ptext (sLit "A foreign-imported address (via &foo) must have type (Ptr a) or (FunPtr a)") ]
illegalForeignTyErr :: SDoc -> Type -> SDoc
illegalForeignTyErr arg_or_res ty
= hang (hsep [ptext (sLit "Unacceptable"), arg_or_res,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment