Don't suggest deprecated flags in error messages
authorMartin Ceresa <ceresa@cifasis-conicet.gov.ar>
Fri, 7 Oct 2016 12:54:10 +0000 (13:54 +0100)
committerMatthew Pickering <matthewtpickering@gmail.com>
Fri, 7 Oct 2016 12:55:09 +0000 (13:55 +0100)
When looking up flags, we make sure to lookup the non-deprecated flags first
by ordering the list of flags.

Reviewers: bgamari, austin, mpickering

Reviewed By: mpickering

Subscribers: mpickering, thomie

Differential Revision: https://phabricator.haskell.org/D2541

GHC Trac Issues: #12574

compiler/main/DynFlags.hs
testsuite/tests/warnings/should_compile/T11077.stderr
testsuite/tests/warnings/should_compile/T12574.hs [new file with mode: 0644]
testsuite/tests/warnings/should_compile/T12574.stderr [new file with mode: 0644]
testsuite/tests/warnings/should_compile/T2526.stderr
testsuite/tests/warnings/should_compile/all.T

index 97a6211..63bb0ef 100644 (file)
@@ -3236,7 +3236,15 @@ flagSpecOf flag = listToMaybe $ filter check wWarningFlags
 
 -- | These @-W\<blah\>@ flags can all be reversed with @-Wno-\<blah\>@
 wWarningFlags :: [FlagSpec WarningFlag]
-wWarningFlags = map snd wWarningFlagsDeps
+wWarningFlags = wWarningFlagsDepsCurrent ++ wWarningFlagsDepsDeprecated
+  where
+    deprecatedWFlags = filter (not . isCurr) wWarningFlagsDeps
+    currentWFlags = filter isCurr wWarningFlagsDeps
+    wWarningFlagsDepsCurrent = map snd currentWFlags
+    wWarningFlagsDepsDeprecated = map snd deprecatedWFlags
+
+    isCurr ( Deprecated , _ ) = False
+    isCurr _ = True
 
 wWarningFlagsDeps :: [(Deprecation, FlagSpec WarningFlag)]
 wWarningFlagsDeps = [
index ba7d4d8..1d68043 100644 (file)
@@ -1,3 +1,3 @@
 
-T11077.hs:3:1: warning: [-Wmissing-exported-sigs]
+T11077.hs:3:1: warning: [-Wmissing-exported-signatures]
     Top-level binding with no type signature: foo :: a
diff --git a/testsuite/tests/warnings/should_compile/T12574.hs b/testsuite/tests/warnings/should_compile/T12574.hs
new file mode 100644 (file)
index 0000000..7f54e7a
--- /dev/null
@@ -0,0 +1,3 @@
+module T12574 where
+
+id a = a
diff --git a/testsuite/tests/warnings/should_compile/T12574.stderr b/testsuite/tests/warnings/should_compile/T12574.stderr
new file mode 100644 (file)
index 0000000..ded8833
--- /dev/null
@@ -0,0 +1,4 @@
+
+T12574.hs:3:1: warning: [-Wmissing-local-signatures]
+    Polymorphic local binding with no type signature:
+      T12574.id :: forall t. t -> t
index 07cf8d8..b433f0e 100644 (file)
@@ -1,3 +1,3 @@
 
-T2526.hs:4:1: warning: [-Wmissing-exported-sigs]
+T2526.hs:4:1: warning: [-Wmissing-exported-signatures]
     Top-level binding with no type signature: foo :: Integer
index d2c8c1a..ed128fa 100644 (file)
@@ -13,6 +13,9 @@ test('T11128', normal, compile, [''])
 test('T11128b', normal, compile, [''])
 test('PluralS', normal, compile, [''])
 
+# T12574 Test that suggest current flag over deprecated
+test('T12574',normal, compile, ['-fwarn-missing-local-signatures'])
+
 test('DeprU',
        extra_clean([
                'DeprM.o',  'DeprU.o',