| Opt_DoStgLinting
| Opt_DoUSPLinting
+ | Opt_WarnIsError -- -Werror; makes warnings fatal
| Opt_WarnDuplicateExports
| Opt_WarnHiShadows
| Opt_WarnIncompletePatterns
-----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.105 2002/10/17 14:26:17 simonmar Exp $
+-- $Id: DriverFlags.hs,v 1.106 2002/11/20 09:37:48 simonpj Exp $
--
-- Driver flags
--
------ Warning opts -------------------------------------------------
, ( "W" , NoArg (mapM_ setDynFlag minusWOpts) )
+ , ( "Werror" , NoArg (setDynFlag Opt_WarnIsError) )
, ( "Wall" , NoArg (mapM_ setDynFlag minusWallOpts) )
, ( "Wnot" , NoArg (mapM_ unSetDynFlag minusWallOpts) ) /* DEPREC */
, ( "w" , NoArg (mapM_ unSetDynFlag minusWallOpts) )
\begin{code}
module ErrUtils (
ErrMsg, WarnMsg, Message,
- Messages, errorsFound, warningsFound, emptyMessages,
+ Messages, errorsFound, emptyMessages,
addShortErrLocLine, addShortWarnLocLine,
addErrLocHdrLine, addWarnLocHdrLine, dontAddErrLoc,
emptyMessages :: Messages
emptyMessages = (emptyBag, emptyBag)
-errorsFound :: Messages -> Bool
-errorsFound (warns, errs) = not (isEmptyBag errs)
-
-warningsFound :: Messages -> Bool
-warningsFound (warns, errs) = not (isEmptyBag warns)
+errorsFound :: DynFlags -> Messages -> Bool
+-- The dyn-flags are used to see if the user has specified
+-- -Werorr, which says that warnings should be fatal
+errorsFound dflags (warns, errs)
+ | dopt Opt_WarnIsError dflags = not (isEmptyBag errs) || not (isEmptyBag warns)
+ | otherwise = not (isEmptyBag errs)
printErrorsAndWarnings :: Messages -> IO ()
-- Don't print any warnings if there are errors
eps' <- readIORef eps_var ;
nc' <- readIORef nc_var ;
let { pcs' = PCS { pcs_EPS = eps', pcs_nc = nc' } ;
- final_res | errorsFound msgs = Nothing
- | otherwise = maybe_res } ;
+ final_res | errorsFound dflags msgs = Nothing
+ | otherwise = maybe_res } ;
return (pcs', final_res)
}
new_errs <- readMutVar errs_var ;
+ dflags <- getDOpts ;
+
return (new_errs,
case mb_r of
- Left exn -> Nothing
- Right r | errorsFound new_errs -> Nothing
- | otherwise -> Just r)
+ Left exn -> Nothing
+ Right r | errorsFound dflags new_errs -> Nothing
+ | otherwise -> Just r)
}
tryTcLIE :: TcM a -> TcM (Messages, Maybe a)
ifErrsM bale_out normal
= do { errs_var <- getErrsVar ;
msgs <- readMutVar errs_var ;
- if errorsFound msgs then
+ dflags <- getDOpts ;
+ if errorsFound dflags msgs then
bale_out
else
normal }
<entry>dynamic</entry>
<entry><option>-w</option></entry>
</row>
+ <row>
+ <entry><option>-Werror</option></entry>
+ <entry>make warnings fatal</entry>
+ <entry>dynamic</entry>
+ <entry></entry>
+ </row>
<row>
<entry><option>-fwarn-deprecations</option></entry>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>-Werror</option>:</term>
+ <listitem>
+ <indexterm><primary><option>-Werror</option></primary></indexterm>
+ <para>Makes any warning into a fatal error. Useful so that you don't
+ miss warnings when doing batch compilation. </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
<para>The full set of warning options is described below. To turn