Commit c3939fdb authored by ian@well-typed.com's avatar ian@well-typed.com

Make the -ferror-spans flag dynamic

parent f7cd14fd
......@@ -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 ),
......
......@@ -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:")
......
......@@ -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",
......
......@@ -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
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment