X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fparser%2FRdrHsSyn.lhs;h=87741b950d872b5252a1b35f291f33a895a8233b;hb=15486d73d84483243f40fa245e63e7e88d5ed0ad;hp=ace6fd0e5e9cb141922eebb4ff2b028eb000140c;hpb=e6d057711f4d6d6ff6342c39fa2b9e44d25447f1;p=ghc-hetmet.git diff --git a/compiler/parser/RdrHsSyn.lhs b/compiler/parser/RdrHsSyn.lhs index ace6fd0..87741b9 100644 --- a/compiler/parser/RdrHsSyn.lhs +++ b/compiler/parser/RdrHsSyn.lhs @@ -40,6 +40,7 @@ module RdrHsSyn ( checkSynHdr, -- LHsType RdrName -> P (Located RdrName, [LHsTyVarBndr RdrName], [LHsType RdrName]) checkKindSigs, -- [LTyClDecl RdrName] -> P () checkInstType, -- HsType -> P HsType + checkDerivDecl, -- LDerivDecl RdrName -> P (LDerivDecl RdrName) checkPattern, -- HsExp -> P HsPat checkPatterns, -- SrcLoc -> [HsExp] -> P [HsPat] checkDo, -- [Stmt] -> P [Stmt] @@ -56,7 +57,7 @@ import RdrName ( RdrName, isRdrTyVar, mkUnqual, rdrNameOcc, isRdrDataCon, isUnqual, getRdrName, isQual, setRdrNameSpace ) import BasicTypes ( maxPrecedence, Activation, InlineSpec(..), alwaysInlineSpec, neverInlineSpec ) -import Lexer ( P, failSpanMsgP, extension, bangPatEnabled ) +import Lexer ( P, failSpanMsgP, extension, glaExtsEnabled, bangPatEnabled ) import TysWiredIn ( unitTyCon ) import ForeignCall ( CCallConv, Safety, CCallTarget(..), CExportSpec(..), DNCallSpec(..), DNKind(..), CLabelString ) @@ -311,6 +312,8 @@ add gp@(HsGroup {hs_valds = ts}) l (ValD d) ds -- The rest are routine add gp@(HsGroup {hs_instds = ts}) l (InstD d) ds = addl (gp { hs_instds = L l d : ts }) ds +add gp@(HsGroup {hs_derivds = ts}) l (DerivD d) ds + = addl (gp { hs_derivds = L l d : ts }) ds add gp@(HsGroup {hs_defds = ts}) l (DefD d) ds = addl (gp { hs_defds = L l d : ts }) ds add gp@(HsGroup {hs_fords = ts}) l (ForD d) ds @@ -559,6 +562,16 @@ checkDictTy (L spn ty) = check ty [] check (HsParTy t) args = check (unLoc t) args check _ _ = parseError spn "Malformed context in instance header" + +--------------------------------------------------------------------------- +-- Checking stand-alone deriving declarations + +checkDerivDecl :: LDerivDecl RdrName -> P (LDerivDecl RdrName) +checkDerivDecl d@(L loc _) = + do glaExtOn <- extension glaExtsEnabled + if glaExtOn then return d + else parseError loc "Illegal stand-alone deriving declaration (use -fglasgow-exts)" + --------------------------------------------------------------------------- -- Checking statements in a do-expression -- We parse do { e1 ; e2 ; }