summaryrefslogtreecommitdiff
path: root/compiler/main/ErrUtils.hs
diff options
context:
space:
mode:
authorMaciej Bielecki <zyla@prati.pl>2016-11-21 17:08:45 -0500
committerBen Gamari <ben@smart-cactus.org>2016-11-21 17:08:57 -0500
commit514acfe4c4e61941c2fa2e06cff02f6e4424e5e6 (patch)
tree7b08577f13bb839083d3d194d75069547fb00cd5 /compiler/main/ErrUtils.hs
parentea76a213d14709ded827abeb2246e4daa154e92e (diff)
downloadhaskell-514acfe4c4e61941c2fa2e06cff02f6e4424e5e6.tar.gz
Implement fine-grained `-Werror=...` facility
This patch add new options `-Werror=...`, `-Wwarn=...` and `-Wno-error=...` (synonym for `-Wwarn=...`). Semantics: - `-Werror` marks all warnings as fatal, including those that don't have a warning flag, and CPP warnings. - `-Werror=...` enables a warning and marks it as fatal - `-Wwarn=...` marks a warning as non-fatal, but doesn't disable it Test Plan: validate Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: mpickering, svenpanne, RyanGlScott, thomie Differential Revision: https://phabricator.haskell.org/D2706 GHC Trac Issues: #11219
Diffstat (limited to 'compiler/main/ErrUtils.hs')
-rw-r--r--compiler/main/ErrUtils.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/main/ErrUtils.hs b/compiler/main/ErrUtils.hs
index 41150a6383..db593509c9 100644
--- a/compiler/main/ErrUtils.hs
+++ b/compiler/main/ErrUtils.hs
@@ -20,6 +20,7 @@ module ErrUtils (
unionMessages,
errMsgSpan, errMsgContext,
errorsFound, isEmptyMessages,
+ isWarnMsgFatal,
-- ** Formatting
pprMessageBag, pprErrMsgBagWithLoc,
@@ -553,3 +554,9 @@ prettyPrintGhcErrors dflags
pprDebugAndThen dflags pgmError (text str) doc
_ ->
liftIO $ throwIO e
+
+-- | Checks if given 'WarnMsg' is a fatal warning.
+isWarnMsgFatal :: DynFlags -> WarnMsg -> Bool
+isWarnMsgFatal dflags ErrMsg{errMsgReason = Reason wflag}
+ = wopt_fatal wflag dflags
+isWarnMsgFatal dflags _ = gopt Opt_WarnIsError dflags