X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fmain%2FErrUtils.lhs;h=b9e739f1def621353814bd3355bb3966c0eecf3e;hb=a7f88c2f7900257d6791286f653cf141ebcb81c4;hp=72d0e930bcb347de0c015a0b0cc2988beb892a69;hpb=b4229ab662b6d87b1477bafa85d2db46e5a9a152;p=ghc-hetmet.git diff --git a/compiler/main/ErrUtils.lhs b/compiler/main/ErrUtils.lhs index 72d0e93..b9e739f 100644 --- a/compiler/main/ErrUtils.lhs +++ b/compiler/main/ErrUtils.lhs @@ -13,6 +13,7 @@ module ErrUtils ( Messages, errorsFound, emptyMessages, mkErrMsg, mkWarnMsg, mkPlainErrMsg, mkLongErrMsg, printErrorsAndWarnings, printBagOfErrors, printBagOfWarnings, + handleFlagWarnings, ghcExit, doIfSet, doIfSet_dyn, @@ -28,8 +29,6 @@ module ErrUtils ( debugTraceMsg, ) where --- XXX This define is a bit of a hack, and should be done more nicely -#define FAST_STRING_NOT_NEEDED 1 #include "HsVersions.h" import Bag ( Bag, bagToList, isEmptyBag, emptyBag ) @@ -40,6 +39,7 @@ import SrcLoc ( srcSpanStart, noSrcSpan ) import DynFlags ( DynFlags(..), DynFlag(..), dopt ) import StaticFlags ( opt_ErrorSpans ) +import Control.Monad import System.Exit ( ExitCode(..), exitWith ) import Data.Dynamic import Data.List @@ -128,10 +128,13 @@ errorsFound dflags (warns, errs) printErrorsAndWarnings :: DynFlags -> Messages -> IO () printErrorsAndWarnings dflags (warns, errs) - | no_errs && no_warns = return () - | no_errs = printBagOfWarnings dflags warns - -- Don't print any warnings if there are errors - | otherwise = printBagOfErrors dflags errs + | no_errs && no_warns = return () + | no_errs = do printBagOfWarnings dflags warns + when (dopt Opt_WarnIsError dflags) $ + errorMsg dflags $ + text "\nFailing due to -Werror.\n" + -- Don't print any warnings if there are errors + | otherwise = printBagOfErrors dflags errs where no_warns = isEmptyBag warns no_errs = isEmptyBag errs @@ -172,7 +175,16 @@ printBagOfWarnings dflags bag_of_warns EQ -> True GT -> False - +handleFlagWarnings :: DynFlags -> [String] -> IO () +handleFlagWarnings _ [] = return () +handleFlagWarnings dflags warns + = do -- It would be nicer if warns :: [Message], but that has circular + -- import problems. + let warns' = map text warns + mapM_ (log_action dflags SevWarning noSrcSpan defaultUserStyle) warns' + when (dopt Opt_WarnIsError dflags) $ + do errorMsg dflags $ text "\nFailing due to -Werror.\n" + exitWith (ExitFailure 1) ghcExit :: DynFlags -> Int -> IO () ghcExit dflags val