diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-08-26 15:09:03 +0100 |
---|---|---|
committer | Andreas Klebinger <klebinger.andreas@gmx.at> | 2021-09-07 16:15:41 +0000 |
commit | 9d73c598d58595f303bb12b2cabf85d4725568c4 (patch) | |
tree | 9dc74fe01105014a11226252032b0c4fb24a9a5b /compiler/GHC/Parser/PostProcess.hs | |
parent | 2735f5a6103eb99e44776da0f5b9d35a18279cbc (diff) | |
download | haskell-wip/t20272.tar.gz |
ffi: Don't allow wrapper stub with CApi conventionwip/t20272
Fixes #20272
Diffstat (limited to 'compiler/GHC/Parser/PostProcess.hs')
-rw-r--r-- | compiler/GHC/Parser/PostProcess.hs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs index 4eab0c1486..af92355240 100644 --- a/compiler/GHC/Parser/PostProcess.hs +++ b/compiler/GHC/Parser/PostProcess.hs @@ -2528,9 +2528,13 @@ mkImport :: Located CCallConv -> P (EpAnn [AddEpAnn] -> HsDecl GhcPs) mkImport cconv safety (L loc (StringLiteral esrc entity _), v, ty) = case unLoc cconv of - CCallConv -> mkCImport - CApiConv -> mkCImport - StdCallConv -> mkCImport + CCallConv -> returnSpec =<< mkCImport + CApiConv -> do + imp <- mkCImport + if isCWrapperImport imp + then addFatalError $ mkPlainErrorMsgEnvelope loc PsErrInvalidCApiImport + else returnSpec imp + StdCallConv -> returnSpec =<< mkCImport PrimCallConv -> mkOtherImport JavaScriptCallConv -> mkOtherImport where @@ -2543,7 +2547,10 @@ mkImport cconv safety (L loc (StringLiteral esrc entity _), v, ty) = case parseCImport cconv safety (mkExtName (unLoc v)) e (L loc esrc) of Nothing -> addFatalError $ mkPlainErrorMsgEnvelope loc $ PsErrMalformedEntityString - Just importSpec -> returnSpec importSpec + Just importSpec -> return importSpec + + isCWrapperImport (CImport _ _ _ CWrapper _) = True + isCWrapperImport _ = False -- currently, all the other import conventions only support a symbol name in -- the entity string. If it is missing, we use the function name instead. |