Support for -fwarn-unused-do-bind and -fwarn-wrong-do-bind, as per #3263
[ghc-hetmet.git] / ghc / Main.hs
index 766577e..c078cdb 100644 (file)
 
 module Main (main) where
 
-#include "HsVersions.h"
-
 -- The official GHC API
 import qualified GHC
 import GHC             ( DynFlags(..), HscTarget(..),
                           GhcMode(..), GhcLink(..),
-                         LoadHowMuch(..), dopt, DynFlag(..) )
+                         LoadHowMuch(..), dopt, DynFlag(..),
+                          defaultCallbacks )
 import CmdLineParser
 
 -- Implementations of the various modes (--show-iface, mkdependHS. etc.)
@@ -153,7 +152,11 @@ main =
   let flagWarnings = staticFlagWarnings
                   ++ modeFlagWarnings
                   ++ dynamicFlagWarnings
-  liftIO $ handleFlagWarnings dflags2 flagWarnings
+
+  handleSourceError (\e -> do
+       GHC.printExceptionAndWarnings e
+       liftIO $ exitWith (ExitFailure 1)) $
+    handleFlagWarnings dflags2 flagWarnings
 
         -- make sure we clean up after ourselves
   GHC.defaultCleanupHandler dflags2 $ do
@@ -161,7 +164,7 @@ main =
   liftIO $ showBanner cli_mode dflags2
 
   -- we've finished manipulating the DynFlags, update the session
-  GHC.setSessionDynFlags dflags2
+  _ <- GHC.setSessionDynFlags dflags2
   dflags3 <- GHC.getSessionDynFlags
   hsc_env <- GHC.getSession
 
@@ -511,7 +514,7 @@ doMake srcs  = do
 
 doShowIface :: DynFlags -> FilePath -> IO ()
 doShowIface dflags file = do
-  hsc_env <- newHscEnv dflags
+  hsc_env <- newHscEnv defaultCallbacks dflags
   showIface hsc_env file
 
 -- ---------------------------------------------------------------------------