Commit 3483c3de authored by Alfredo Di Napoli's avatar Alfredo Di Napoli Committed by Marge Bot

Correct warning for deprecated and unrecognised flags

Fixes #19616.

This commit changes the `GHC.Driver.Errors.handleFlagWarnings` function
to rely on the newly introduced `DiagnosticReason`. This allows us to
correctly pretty-print the flags which triggered some warnings and in
turn remove the cruft around this function (like the extra filtering
and the `shouldPrintWarning` function.
parent 49528121
Pipeline #33970 canceled with stages
in 31 seconds
......@@ -36,22 +36,12 @@ printBagOfErrors logger dflags bag_of_errors
handleFlagWarnings :: Logger -> DynFlags -> [CmdLine.Warn] -> IO ()
handleFlagWarnings logger dflags warns = do
let warns' = filter (should_print_warning dflags . CmdLine.warnReason) warns
-- It would be nicer if warns :: [Located SDoc], but that
let -- It would be nicer if warns :: [Located SDoc], but that
-- has circular import problems.
bag = listToBag [ mkPlainMsgEnvelope dflags WarningWithoutFlag loc (text warn)
| CmdLine.Warn _ (L loc warn) <- warns' ]
bag = listToBag [ mkPlainMsgEnvelope dflags reason loc (text warn)
| CmdLine.Warn reason (L loc warn) <- warns ]
printOrThrowDiagnostics logger dflags bag
where
-- Given a warn reason, check to see if it's associated -W opt is enabled
should_print_warning :: DynFlags -> DiagnosticReason -> Bool
should_print_warning dflags (WarningWithFlag Opt_WarnDeprecatedFlags)
= wopt Opt_WarnDeprecatedFlags dflags
should_print_warning dflags (WarningWithFlag Opt_WarnUnrecognisedWarningFlags)
= wopt Opt_WarnUnrecognisedWarningFlags dflags
should_print_warning _ _
= True
-- | Given a bag of diagnostics, turn them into an exception if
-- any has 'SevError', or print them out otherwise.
......
bkp09.bkp:1:26: warning:
bkp09.bkp:1:26: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
[1 of 5] Processing p
[1 of 1] Compiling H[sig] ( p/H.hsig, nothing )
......
bkp15.bkp:1:26: warning:
bkp15.bkp:1:26: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
[1 of 5] Processing p
[1 of 1] Compiling H[sig] ( p/H.hsig, nothing )
......
ds041.hs:1:14: warning:
ds041.hs:1:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
ds041.hs:16:7: warning: [-Wmissing-fields (in -Wdefault)]
......
T4325.hs:1:14:
Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T4325.hs:1:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T4966.hs:3:14: warning:
T4966.hs:3:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T4966.hs:35:30: warning: [-Wmissing-methods (in -Wdefault)]
......
drv-foldable-traversable1.hs:4:32: warning:
drv-foldable-traversable1.hs:4:32: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
drv-functor1.hs:6:14: warning:
drv-functor1.hs:6:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
drvfail-functor2.hs:2:29: warning:
drvfail-functor2.hs:2:29: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
drvfail-functor2.hs:8:14: error:
......
on the commandline: warning: unrecognised warning flag: -Wfoobar
on the commandline: warning: [-Wunrecognised-warning-flags (in -Wdefault)]
unrecognised warning flag: -Wfoobar
on the commandline: error: [-Werror]
on the commandline: error: [-Wunrecognised-warning-flags, -Werror=unrecognised-warning-flags]
unrecognised warning flag: -Wfoobar
on the commandline: warning: unrecognised warning flag: -Wbar
on the commandline: warning: [-Wunrecognised-warning-flags (in -Wdefault)]
unrecognised warning flag: -Wbar
on the commandline: warning:
on the commandline: warning: [-Wdeprecated-flags (in -Wdefault)]
-XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
on the commandline: warning: unrecognised warning flag: -Wbar
on the commandline: warning: [-Wunrecognised-warning-flags (in -Wdefault)]
unrecognised warning flag: -Wbar
T2464.hs:3:16:
Warning: -fffi is deprecated: use -XForeignFunctionInterface or pragma {-# LANGUAGE ForeignFunctionInterface #-} instead
T2464.hs:3:16: warning: [-Wdeprecated-flags (in -Wdefault)]
-fffi is deprecated: use -XForeignFunctionInterface or pragma {-# LANGUAGE ForeignFunctionInterface #-} instead
GenCannotDoRep0_0.hs:6:14: warning:
GenCannotDoRep0_0.hs:6:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
GenCannotDoRep0_0.hs:13:45: error:
......
GenCannotDoRep0_1.hs:1:29: Warning:
GenCannotDoRep0_1.hs:1:29: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
GenCannotDoRep0_1.hs:8:49:
......
GenCannotDoRep1_1.hs:1:29: Warning:
GenCannotDoRep1_1.hs:1:29: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
GenCannotDoRep1_1.hs:8:49:
......
ghci031.hs:1:14: Warning:
ghci031.hs:1:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T3418.hs:1:28:
Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T3418.hs:1:28: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T3787.hs:20:51: warning:
T3787.hs:20:51: warning: [-Wdeprecated-flags (in -Wdefault)]
-XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
T16619.hs:2:12: warning:
T16619.hs:2:12: warning: [-Wdeprecated-flags (in -Wdefault)]
-Wmissing-space-after-bang is deprecated: bang patterns can no longer be written with a space
read018.hs:1:14:
Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
read018.hs:1:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T16270.hs:3:12: warning:
T16270.hs:3:12: warning: [-Wdeprecated-flags (in -Wdefault)]
-Werror=missing-space-after-bang is deprecated: bang patterns can no longer be written with a space
T16270.hs:8:1: warning: [-Wtabs (in -Wdefault)]
......
WildcardInADTContext1.hs:1:37: warning:
WildcardInADTContext1.hs:1:37: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
WildcardInADTContext1.hs:4:13: error:
......
WildcardInADTContext2.hs:1:53: warning:
WildcardInADTContext2.hs:1:53: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
WildcardInADTContext2.hs:4:10: error:
......
RnFail055.hs:2:73: warning:
RnFail055.hs:2:73: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
RnFail055.hs-boot:2:73: warning:
RnFail055.hs-boot:2:73: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
RnFail055.hs-boot:5:1: error:
......
T8958.hs:2:31: warning:
T8958.hs:2:31: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
TYPE CONSTRUCTORS
newtype Map{2} :: * -> * -> *
......
SafeInfered05.hs:3:14: warning:
SafeInfered05.hs:3:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
[1 of 2] Compiling SafeInfered05_A ( SafeInfered05_A.hs, SafeInfered05_A.o )
......
UnsafeInfered18.hs:4:14: warning:
UnsafeInfered18.hs:4:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
str001.hs:1:14:
Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
str001.hs:1:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T17567StupidThetaB.hs:2:37: warning:
T17567StupidThetaB.hs:2:37: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T2478.hs:1:41:
Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T2478.hs:1:41: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T4355.hs:3:172: warning:
T4355.hs:3:172: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
tc182.hs:1:14:
Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
tc182.hs:1:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T17567StupidTheta.hs:1:37: warning:
T17567StupidTheta.hs:1:37: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
T17567StupidTheta.hs:6:1: error:
......
tcfail067.hs:1:14: warning:
tcfail067.hs:1:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
tcfail067.hs:12:16: error:
......
tcfail102.hs:1:14: warning:
tcfail102.hs:1:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
tcfail102.hs:9:15: error:
......
tcfail125.hs:1:14: warning:
tcfail125.hs:1:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
tcfail125.hs:11:4: error:
......
tcfail133.hs:2:61: warning:
tcfail133.hs:2:61: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
tcfail133.hs:68:7: error:
......
tcfail137.hs:1:14: Warning:
tcfail137.hs:1:14: warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
tcfail137.hs:8:5:
......
tcfail151.hs:1:14: Warning:
tcfail151.hs:1:14: Warning: [-Wdeprecated-flags (in -Wdefault)]
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
tcfail151.hs:8:6:
......
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