[commit: ghc] master: Ignore ANN pragmas with no TH and no external interpreter. (7567b9d)

git at git.haskell.org git at git.haskell.org
Mon May 1 14:52:22 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/7567b9ddba7c4304e8d0226e9bf82a054f37ce91/ghc

>---------------------------------------------------------------

commit 7567b9ddba7c4304e8d0226e9bf82a054f37ce91
Author: Shea Levy <shea at shealevy.com>
Date:   Sun Apr 30 23:20:54 2017 -0400

    Ignore ANN pragmas with no TH and no external interpreter.
    
    Reviewers: hvr, austin, bgamari, RyanGlScott
    
    Reviewed By: bgamari
    
    Subscribers: angerman, RyanGlScott, rwbarton, thomie
    
    GHC Trac Issues: #13609
    
    Differential Revision: https://phabricator.haskell.org/D3496


>---------------------------------------------------------------

7567b9ddba7c4304e8d0226e9bf82a054f37ce91
 compiler/typecheck/TcAnnotations.hs | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/compiler/typecheck/TcAnnotations.hs b/compiler/typecheck/TcAnnotations.hs
index 7b3cc65..43d2970 100644
--- a/compiler/typecheck/TcAnnotations.hs
+++ b/compiler/typecheck/TcAnnotations.hs
@@ -22,8 +22,31 @@ import TcRnMonad
 import SrcLoc
 import Outputable
 
+-- Some platforms don't support the external interpreter, and
+-- compilation on those platforms shouldn't fail just due to
+-- annotations
+#ifndef GHCI
 tcAnnotations :: [LAnnDecl Name] -> TcM [Annotation]
-tcAnnotations anns = mapM tcAnnotation anns
+tcAnnotations anns = do
+  dflags <- getDynFlags
+  case gopt Opt_ExternalInterpreter dflags of
+    True  -> tcAnnotations' anns
+    False -> warnAnns anns
+warnAnns :: [LAnnDecl Name] -> TcM [Annotation]
+--- No GHCI; emit a warning (not an error) and ignore. cf Trac #4268
+warnAnns [] = return []
+warnAnns anns@(L loc _ : _)
+  = do { setSrcSpan loc $ addWarnTc NoReason $
+             (text "Ignoring Ann annotation" <> plural anns <> comma
+             <+> text "because this is a stage-1 compiler without -fexternal-interpreter or doesn't support GHCi")
+       ; return [] }
+#else
+tcAnnotations :: [LAnnDecl Name] -> TcM [Annotation]
+tcAnnotations = tcAnnotations'
+#endif
+
+tcAnnotations' :: [LAnnDecl Name] -> TcM [Annotation]
+tcAnnotations' anns = mapM tcAnnotation anns
 
 tcAnnotation :: LAnnDecl Name -> TcM Annotation
 tcAnnotation (L loc ann@(HsAnnotation _ provenance expr)) = do



More information about the ghc-commits mailing list