Commit 32a9a7f5 authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺

Extend `-Wunrecognised-warning-flag` to cover `-f(no-)warn-*`

The original implementation for #11429 covers only `-W*` flags. However,
old packages will continue to use `-f(no-)warn-*` flags, so it seems
desirable to have `-Wunrecognised-warning-flag` apply to those legacy aliases
as well.

Reviewed By: bgamari

Differential Revision: https://phabricator.haskell.org/D1942
parent a3e0e936
......@@ -2935,14 +2935,16 @@ dynamic_flags_deps = [
wWarningFlagsDeps
++ map (mkFlag turnOff "fno-warn-" unSetWarningFlag . hideFlag)
wWarningFlagsDeps
++ [ (NotDeprecated, unrecognisedWarning "W")
, (NotDeprecated, unrecognisedWarning "fwarn-")
, (NotDeprecated, unrecognisedWarning "fno-warn-") ]
++ map (mkFlag turnOn "f" setExtensionFlag ) fLangFlagsDeps
++ map (mkFlag turnOff "fno-" unSetExtensionFlag) fLangFlagsDeps
++ map (mkFlag turnOn "X" setExtensionFlag ) xFlagsDeps
++ map (mkFlag turnOff "XNo" unSetExtensionFlag) xFlagsDeps
++ map (mkFlag turnOn "X" setLanguage ) languageFlagsDeps
++ map (mkFlag turnOn "X" setSafeHaskell ) safeHaskellFlagsDeps
++ [ (NotDeprecated, unrecognisedWarning)
, make_dep_flag defFlag "XGenerics"
++ [ make_dep_flag defFlag "XGenerics"
(NoArg $ return ())
("it does nothing; look into -XDefaultSignatures " ++
"and -XDeriveGeneric for generic programming support.")
......@@ -2953,13 +2955,13 @@ dynamic_flags_deps = [
-- | This is where we handle unrecognised warning flags. We only issue a warning
-- if -Wunrecognised-warning-flags is set. See Trac #11429 for context.
unrecognisedWarning :: Flag (CmdLineP DynFlags)
unrecognisedWarning = defFlag "W" (Prefix action)
unrecognisedWarning :: String -> Flag (CmdLineP DynFlags)
unrecognisedWarning pfx = defFlag pfx (Prefix action)
where
action :: String -> EwM (CmdLineP DynFlags) ()
action flag = do
f <- wopt Opt_WarnUnrecognisedWarningFlags <$> liftEwM getCmdLineState
when f $ addWarn $ "unrecognised warning flag: -W" ++ flag
when f $ addWarn $ "unrecognised warning flag: -" ++ pfx ++ flag
-- See Note [Supporting CLI completion]
package_flags_deps :: [(Deprecation, Flag (CmdLineP DynFlags))]
......
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