From 183cad171113faf7d44a25116de6586cd4f07578 Mon Sep 17 00:00:00 2001 From: Mateusz Kowalczyk Date: Thu, 5 Sep 2013 01:28:15 +0100 Subject: Fixes #5 --- src/Haddock.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Haddock.hs b/src/Haddock.hs index 398aed4c..a7ac5baf 100644 --- a/src/Haddock.hs +++ b/src/Haddock.hs @@ -34,6 +34,7 @@ import Haddock.GhcUtils hiding (pretty) import Control.Monad hiding (forM_) import Data.Foldable (forM_) +import Data.List (isPrefixOf) import Control.Exception import Data.Maybe import Data.IORef @@ -144,6 +145,10 @@ haddock args = handleTopExceptions $ do Just "YES" -> return $ Flag_OptGhc "-dynamic-too" : flags _ -> return flags + unless (Flag_NoWarnings `elem` flags) $ do + forM_ (warnings args) $ \warning -> do + hPutStrLn stderr warning + withGhc' flags' $ do dflags <- getDynFlags @@ -171,6 +176,12 @@ haddock args = handleTopExceptions $ do -- Render even though there are no input files (usually contents/index). liftIO $ renderStep dflags flags qual packages [] +-- | Create warnings about potential misuse of -optghc +warnings :: [String] -> [String] +warnings = map format . filter (isPrefixOf "-optghc") + where + format arg = concat ["Warning: `", arg, "' means `-o ", drop 2 arg, "', did you mean `-", arg, "'?"] + withGhc' :: [Flag] -> Ghc a -> IO a withGhc' flags action = do -- cgit v1.2.3