[commit: ghc] master: Fix #12099: Remove bogus flags (bcb419a)

git at git.haskell.org git at git.haskell.org
Fri Jun 10 14:18:52 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/bcb419a41754bbd883973c96d4b0bca4639e4f2d/ghc

>---------------------------------------------------------------

commit bcb419a41754bbd883973c96d4b0bca4639e4f2d
Author: Sean Gillespie <sean at mistersg.net>
Date:   Fri Jun 10 12:53:37 2016 +0200

    Fix #12099: Remove bogus flags
    
    Remove -fwarn- and -fno-warn- from flagsForCompletion
    
    Testcase: Fix linter error on T12099
    
    For Issue #12099
    
    Reviewers: austin, thomie, bgamari
    
    Reviewed By: austin, thomie, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2281
    
    GHC Trac Issues: #12099


>---------------------------------------------------------------

bcb419a41754bbd883973c96d4b0bca4639e4f2d
 compiler/main/DynFlags.hs                          |  8 +++----
 testsuite/tests/ghc-api/T12099.hs                  | 27 ++++++++++++++++++++++
 .../{arityanal/Makefile => ghc-api/T12099.stdout}  |  0
 testsuite/tests/ghc-api/all.T                      |  1 +
 4 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 30d4d30..5515b8c 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -2994,9 +2994,9 @@ dynamic_flags_deps = [
     wWarningFlagsDeps
  ++ map (mkFlag turnOff "fno-warn-" unSetWarningFlag . hideFlag)
     wWarningFlagsDeps
- ++ [ (NotDeprecated, unrecognisedWarning "W")
-    , (NotDeprecated, unrecognisedWarning "fwarn-")
-    , (NotDeprecated, unrecognisedWarning "fno-warn-") ]
+ ++ [ (NotDeprecated, unrecognisedWarning "W"),
+      (Deprecated,    unrecognisedWarning "fwarn-"),
+      (Deprecated,    unrecognisedWarning "fno-warn-") ]
  ++ map (mkFlag turnOn  "f"         setExtensionFlag  ) fLangFlagsDeps
  ++ map (mkFlag turnOff "fno-"      unSetExtensionFlag) fLangFlagsDeps
  ++ map (mkFlag turnOn  "X"         setExtensionFlag  ) xFlagsDeps
@@ -3015,7 +3015,7 @@ 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 :: String -> Flag (CmdLineP DynFlags)
-unrecognisedWarning prefix = defFlag prefix (Prefix action)
+unrecognisedWarning prefix = defHiddenFlag prefix (Prefix action)
   where
     action :: String -> EwM (CmdLineP DynFlags) ()
     action flag = do
diff --git a/testsuite/tests/ghc-api/T12099.hs b/testsuite/tests/ghc-api/T12099.hs
new file mode 100644
index 0000000..d5d5d54
--- /dev/null
+++ b/testsuite/tests/ghc-api/T12099.hs
@@ -0,0 +1,27 @@
+module Main where
+
+import DynFlags
+
+import Control.Monad
+import Data.List
+
+-- Verify bogus flags aren't printed on flagsForCompletion and
+-- allNonDeprecatedFlags:
+--  * -fwarn-
+--  * -fno-warn-
+--
+-- Should print nothing
+main :: IO ()
+main = mapM_ print $ fwarnFlags (flagsForCompletion True) ++ nonDepFwarnFlags
+
+-- Get flags beginning with -fwarn- and -fno-warn-
+fwarnFlags :: [String] -> [String]
+fwarnFlags = filter isFwarn
+  where isFwarn flag = any (flip isPrefixOf $ flag) ["-fwarn-", "-fno-warn"]
+
+-- Get suggested flags for -fwarn-, -fno-warn-
+nonDepFwarnFlags :: [String]
+nonDepFwarnFlags = filter isFwarn allNonDeprecatedFlags
+  where isFwarn "-fwarn-"    = True
+        isFwarn "-fno-warn-" = True
+        isFwarn _            = False
diff --git a/testsuite/tests/arityanal/Makefile b/testsuite/tests/ghc-api/T12099.stdout
similarity index 100%
copy from testsuite/tests/arityanal/Makefile
copy to testsuite/tests/ghc-api/T12099.stdout
diff --git a/testsuite/tests/ghc-api/all.T b/testsuite/tests/ghc-api/all.T
index 12c64eb..377c1e3 100644
--- a/testsuite/tests/ghc-api/all.T
+++ b/testsuite/tests/ghc-api/all.T
@@ -26,3 +26,4 @@ test('T9015', extra_run_opts('"' + config.libdir + '"'),
               ['-package ghc'])
 test('T11579', extra_run_opts('"' + config.libdir + '"'), compile_and_run,
      ['-package ghc'])
+test('T12099', normal, compile_and_run, ['-package ghc'])



More information about the ghc-commits mailing list