Commit 71b73094 authored by Matt Renaud's avatar Matt Renaud

Fix failing unit tests.

Some fixes due to reported flag changes in stderr output from -Wdeprecations to
-Wwarnings-deprecations (expected).

Other changes were due to incorrectly including deprecations warnings when
-fno-warn-deprecations were set because in RsEnv and RnName it checked for
any of the flags being, regardless of if the warning came from use of
WARNING or DEPRECATED. A new function has been added to DynFlags.hs which
verifies that the "deprecation type" matches the set of enabled warning
flags (deprecationTypeMatchesFlag).

- overloadedrecflds/should_fail/overloadedrecfldsfail11.run  overloadedrecfldsfail11 [stderr mismatch] (normal)
    FIXED: Use of a overloaded record field marked with WARNING should trigger
    -Wwarnings-deprecations instead of -Wdeprecations.

- overloadedrecflds/should_fail/overloadedrecfldsfail12.run  overloadedrecfldsfail12 [stderr mismatch] (normal)
    FIXED: Use of a symbol with WARNING should trigger -Wwarnings-deprecations instead of -Wdeprecations.

- rename/should_compile/rn066.run                            rn066 [stderr mismatch] (normal)
    FIXED: Use of a symbol with WARNING should trigger -Wwarnings-deprecations instead of -Wdeprecations.

- safeHaskell/unsafeLibs/GoodImport03.run                    GoodImport03 [stderr mismatch] (normal)
    FIXED: Check for WARNING/DEPRECATION when adding warnings and match with flags.

- typecheck/should_compile/tc223.run                         tc223 [stderr mismatch] (normal)
    FIXED: Check for WARNING/DEPRECATION when adding warnings and match with flags.
parent 02bdf026
Pipeline #950 failed with stages
in 703 minutes and 24 seconds
......@@ -22,7 +22,7 @@ module DynFlags (
DumpFlag(..),
GeneralFlag(..),
WarningFlag(..), WarnReason(..),
warningTextToWarningFlag,
deprecationTypeMatchesFlags, warningTextToWarningFlag,
Language(..),
PlatformConstants(..),
FatalMessager, LogAction, FlushOut(..), FlushErr(..),
......@@ -839,6 +839,11 @@ data WarningFlag =
| Opt_WarnMissingDerivingStrategies -- Since 8.8
deriving (Eq, Show, Enum)
-- | Returns true if the type of deprecation (WARNING or DEPRECATED)
-- matches the specified warning flags.
deprecationTypeMatchesFlags :: WarningTxt -> DynFlags -> Bool
deprecationTypeMatchesFlags txt = wopt (warningTextToWarningFlag txt)
-- | Convert a 'WarningText' to either 'Opt_WarnDeprecations' or
-- 'Opt_WarnWarningsDeprecations' depending on if the 'WarningTxt'
-- came from a WARNING pragrma or a DEPRECATED pragma.
......@@ -4726,6 +4731,7 @@ smallestGroups flag = mapMaybe go warningHierarchies where
standardWarnings :: [WarningFlag]
standardWarnings -- see Note [Documenting warning flags]
= [ Opt_WarnOverlappingPatterns,
Opt_WarnDeprecations,
Opt_WarnWarningsDeprecations,
Opt_WarnDeprecatedFlags,
Opt_WarnDeferredTypeErrors,
......
......@@ -1242,8 +1242,9 @@ warnIfDeprecated gre@(GRE { gre_name = name, gre_imp = iss })
-- See Note [Handling of deprecations]
do { iface <- loadInterfaceForName doc name
; case lookupImpDeprec iface gre of
Just txt -> addWarn (Reason (warningTextToWarningFlag txt))
(mk_msg imp_spec txt)
Just txt -> when (deprecationTypeMatchesFlags txt dflags) $
addWarn (Reason (warningTextToWarningFlag txt))
(mk_msg imp_spec txt)
Nothing -> return () } }
| otherwise
= return ()
......
......@@ -370,8 +370,9 @@ rnImportDecl this_mod
when (wopt Opt_WarnWarningsDeprecations dflags ||
wopt Opt_WarnDeprecations dflags) (
case (mi_warns iface) of
WarnAll txt -> addWarn (Reason (warningTextToWarningFlag txt))
(moduleWarn imp_mod_name txt)
WarnAll txt -> when (deprecationTypeMatchesFlags txt dflags) $
addWarn (Reason (warningTextToWarningFlag txt))
(moduleWarn imp_mod_name txt)
_ -> return ()
)
......
[1 of 2] Compiling OverloadedRecFldsFail11_A ( OverloadedRecFldsFail11_A.hs, OverloadedRecFldsFail11_A.o )
[2 of 2] Compiling Main ( overloadedrecfldsfail11.hs, overloadedrecfldsfail11.o )
overloadedrecfldsfail11.hs:5:15: error: [-Wdeprecations (in -Wdefault), -Werror=deprecations]
overloadedrecfldsfail11.hs:5:15: error: [-Wwarnings-deprecations (in -Wdefault), -Werror=warnings-deprecations]
In the use of ‘foo’ (imported from OverloadedRecFldsFail11_A):
"Warning on a record field"
[1 of 2] Compiling OverloadedRecFldsFail12_A ( OverloadedRecFldsFail12_A.hs, OverloadedRecFldsFail12_A.o )
[2 of 2] Compiling Main ( overloadedrecfldsfail12.hs, overloadedrecfldsfail12.o )
overloadedrecfldsfail12.hs:10:11: error: [-Wdeprecations (in -Wdefault), -Werror=deprecations]
overloadedrecfldsfail12.hs:10:11: error: [-Wwarnings-deprecations (in -Wdefault), -Werror=warnings-deprecations]
In the use of ‘foo’ (imported from OverloadedRecFldsFail12_A):
"Deprecated foo"
overloadedrecfldsfail12.hs:10:20: error: [-Wdeprecations (in -Wdefault), -Werror=deprecations]
overloadedrecfldsfail12.hs:10:20: error: [-Wwarnings-deprecations (in -Wdefault), -Werror=warnings-deprecations]
In the use of ‘bar’ (imported from OverloadedRecFldsFail12_A):
"Deprecated bar"
overloadedrecfldsfail12.hs:13:5: error: [-Wdeprecations (in -Wdefault), -Werror=deprecations]
overloadedrecfldsfail12.hs:13:5: error: [-Wwarnings-deprecations (in -Wdefault), -Werror=warnings-deprecations]
In the use of ‘foo’ (imported from OverloadedRecFldsFail12_A):
"Deprecated foo"
rn066.hs:13:7: warning: [-Wdeprecations (in -Wdefault)]
rn066.hs:13:7: warning: [-Wwarnings-deprecations (in -Wdefault)]
In the use of ‘op’ (imported from Rn066_A):
"Is that really a good idea?"
rn066.hs:13:10: warning: [-Wdeprecations (in -Wdefault)]
rn066.hs:13:10: warning: [-Wwarnings-deprecations (in -Wdefault)]
In the use of data constructor ‘C’ (imported from Rn066_A):
"Are you sure you want to do that?"
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