Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/c3939fdb9cc66569f781083b08c4a881edfd137d

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

commit c3939fdb9cc66569f781083b08c4a881edfd137d
Author: Ian Lynagh <i...@well-typed.com>
Date:   Tue Oct 9 00:07:15 2012 +0100

    Make the -ferror-spans flag dynamic

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

 compiler/main/DynFlags.hs         |    3 +++
 compiler/main/ErrUtils.lhs        |    8 +++++---
 compiler/main/StaticFlagParser.hs |    3 +--
 compiler/main/StaticFlags.hs      |    8 --------
 docs/users_guide/flags.xml        |    2 +-
 5 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 9639e2e..b89e2be 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -344,6 +344,8 @@ data DynFlag
    | Opt_Hpc
 
    -- output style opts
+   | Opt_ErrorSpans -- Include full span info in error messages,
+                    -- instead of just the start position.
    | Opt_PprCaseAsLet
 
    -- temporary flags
@@ -2205,6 +2207,7 @@ dFlags = [
 -- | These @-f\<blah\>@ flags can all be reversed with @-fno-\<blah\>@
 fFlags :: [FlagSpec DynFlag]
 fFlags = [
+  ( "error-spans",                      Opt_ErrorSpans, nop ),
   ( "print-explicit-foralls",           Opt_PrintExplicitForalls, nop ),
   ( "strictness",                       Opt_Strictness, nop ),
   ( "specialise",                       Opt_Specialise, nop ),
diff --git a/compiler/main/ErrUtils.lhs b/compiler/main/ErrUtils.lhs
index 1643128..b164d1c 100644
--- a/compiler/main/ErrUtils.lhs
+++ b/compiler/main/ErrUtils.lhs
@@ -42,7 +42,6 @@ import Panic
 import FastString
 import SrcLoc
 import DynFlags
-import StaticFlags      ( opt_ErrorSpans )
 
 import System.Directory
 import System.Exit      ( ExitCode(..), exitWith )
@@ -93,8 +92,11 @@ mkLocMessage :: Severity -> SrcSpan -> MsgDoc -> MsgDoc
   -- are supposed to be in a standard format, and one without a location
   -- would look strange.  Better to say explicitly "<no location info>".
 mkLocMessage severity locn msg
-  | opt_ErrorSpans = hang (ppr locn <> colon <+> sev_info) 4 msg
-  | otherwise      = hang (ppr (srcSpanStart locn) <> colon <+> sev_info) 4 msg
+    = sdocWithDynFlags $ \dflags ->
+      let locn' = if dopt Opt_ErrorSpans dflags
+                  then ppr locn
+                  else ppr (srcSpanStart locn)
+      in hang (locn' <> colon <+> sev_info) 4 msg
   where
     sev_info = case severity of
                  SevWarning -> ptext (sLit "Warning:")
diff --git a/compiler/main/StaticFlagParser.hs 
b/compiler/main/StaticFlagParser.hs
index aceb672..9c98836 100644
--- a/compiler/main/StaticFlagParser.hs
+++ b/compiler/main/StaticFlagParser.hs
@@ -134,8 +134,7 @@ isStaticFlag f =
     "fno-flat-cache",
     "fexcess-precision",
     "fhardwire-lib-paths",
-    "fcpr-off",
-    "ferror-spans"
+    "fcpr-off"
     ]
   || any (`isPrefixOf` f) [
     "fliberate-case-threshold",
diff --git a/compiler/main/StaticFlags.hs b/compiler/main/StaticFlags.hs
index 68954a8..598ea00 100644
--- a/compiler/main/StaticFlags.hs
+++ b/compiler/main/StaticFlags.hs
@@ -60,9 +60,6 @@ module StaticFlags (
        opt_UF_KeenessFactor,
        opt_UF_DearOp,
 
-       -- misc opts
-       opt_ErrorSpans,
-
     -- For the parser
     addOpt, removeOpt, v_opt_C_ready,
 
@@ -291,11 +288,6 @@ opt_UF_DictDiscount      = lookup_def_int 
"-funfolding-dict-discount"      (30::
 opt_UF_KeenessFactor    = lookup_def_float "-funfolding-keeness-factor"   
(1.5::Float)
 opt_UF_DearOp            = ( 40 :: Int)
 
-
--- Include full span info in error messages, instead of just the start 
position.
-opt_ErrorSpans :: Bool
-opt_ErrorSpans                 = lookUp (fsLit "-ferror-spans")
-
 -----------------------------------------------------------------------------
 -- Tunneling our global variables into a new instance of the GHC library
 
diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml
index c2e226c..a122e5a 100644
--- a/docs/users_guide/flags.xml
+++ b/docs/users_guide/flags.xml
@@ -86,7 +86,7 @@
           <row>
             <entry><option>-ferror-spans</option></entry>
             <entry>output full span in error messages</entry>
-            <entry>static</entry>
+            <entry>dynamic</entry>
             <entry>-</entry>
           </row>
           <row>



_______________________________________________
Cvs-ghc mailing list
Cvs-ghc@haskell.org
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to