diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2018-06-17 12:51:06 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-06-17 12:51:13 -0400 |
commit | 04e9fe5c7d3c2bac46933e3d647e561cb741edf4 (patch) | |
tree | 1e4f493c98e6df9abf4efafc0887c002bf632330 | |
parent | 008ea12dd93b9f9104f0b532b278a31b719bafb8 (diff) | |
download | haskell-04e9fe5c7d3c2bac46933e3d647e561cb741edf4.tar.gz |
Add -Werror=compat
Add a flag `-Werror=compat` to GHC which has the effect of `-Werror=x
-Werror=y ...`, where `x, y, ...` are warnings from the `-Wcompat`
option group.
Test Plan: ./validate
Reviewers: bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie, carter
GHC Trac Issues: #15278
Differential Revision: https://phabricator.haskell.org/D4860
-rw-r--r-- | compiler/main/DynFlags.hs | 16 | ||||
-rw-r--r-- | docs/users_guide/using-warnings.rst | 6 |
2 files changed, 18 insertions, 4 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 485eb72942..fa210dcce9 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -3522,10 +3522,7 @@ dynamic_flags_deps = [ ++ map (mkFlag turnOff "fno-" unSetGeneralFlag ) fFlagsDeps ++ map (mkFlag turnOn "W" setWarningFlag ) wWarningFlagsDeps ++ map (mkFlag turnOff "Wno-" unSetWarningFlag ) wWarningFlagsDeps - ++ map (mkFlag turnOn "Werror=" (\flag -> do { - ; setWarningFlag flag - ; setFatalWarningFlag flag })) - wWarningFlagsDeps + ++ map (mkFlag turnOn "Werror=" setWErrorFlag ) wWarningFlagsDeps ++ map (mkFlag turnOn "Wwarn=" unSetFatalWarningFlag ) wWarningFlagsDeps ++ map (mkFlag turnOn "Wno-error=" unSetFatalWarningFlag ) @@ -3537,6 +3534,12 @@ dynamic_flags_deps = [ ++ [ (NotDeprecated, unrecognisedWarning "W"), (Deprecated, unrecognisedWarning "fwarn-"), (Deprecated, unrecognisedWarning "fno-warn-") ] + ++ [ make_ord_flag defFlag "Werror=compat" + (NoArg (mapM_ setWErrorFlag minusWcompatOpts)) + , make_ord_flag defFlag "Wno-error=compat" + (NoArg (mapM_ unSetFatalWarningFlag minusWcompatOpts)) + , make_ord_flag defFlag "Wwarn=compat" + (NoArg (mapM_ unSetFatalWarningFlag minusWcompatOpts)) ] ++ map (mkFlag turnOn "f" setExtensionFlag ) fLangFlagsDeps ++ map (mkFlag turnOff "fno-" unSetExtensionFlag) fLangFlagsDeps ++ map (mkFlag turnOn "X" setExtensionFlag ) xFlagsDeps @@ -4802,6 +4805,11 @@ setFatalWarningFlag, unSetFatalWarningFlag :: WarningFlag -> DynP () setFatalWarningFlag f = upd (\dfs -> wopt_set_fatal dfs f) unSetFatalWarningFlag f = upd (\dfs -> wopt_unset_fatal dfs f) +setWErrorFlag :: WarningFlag -> DynP () +setWErrorFlag flag = + do { setWarningFlag flag + ; setFatalWarningFlag flag } + -------------------------- setExtensionFlag, unSetExtensionFlag :: LangExt.Extension -> DynP () setExtensionFlag f = upd (setExtensionFlag' f) diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst index 7dc4a3b048..510b56ad80 100644 --- a/docs/users_guide/using-warnings.rst +++ b/docs/users_guide/using-warnings.rst @@ -151,6 +151,9 @@ to abort. Makes a specific warning into a fatal error. The warning will be enabled if it hasn't been enabled yet. + ``-Werror=compat`` has the same effect as ``-Werror=...`` for each warning + flag in the :ghc-flag:`-Wcompat` option group. + .. ghc-flag:: -Wwarn :shortdesc: make warnings non-fatal :type: dynamic @@ -172,6 +175,9 @@ to abort. Note that it doesn't fully negate the effects of ``-Werror=<wflag>`` - the warning will still be enabled. + ``-Wwarn=compat`` has the same effect as ``-Wwarn=...`` for each warning + flag in the :ghc-flag:`-Wcompat` option group. + When a warning is emitted, the specific warning flag which controls it is shown. |