Handle errors in an OPTIONS pragma when preprocessing
authorIan Lynagh <igloo@earth.li>
Sat, 14 Jun 2008 14:58:40 +0000 (14:58 +0000)
committerIan Lynagh <igloo@earth.li>
Sat, 14 Jun 2008 14:58:40 +0000 (14:58 +0000)
compiler/main/DriverPipeline.hs
compiler/main/GHC.hs
compiler/main/HeaderInfo.hs

index 318dac5..b9de306 100644 (file)
@@ -1214,17 +1214,6 @@ mk_pvm_wrapper_script pvm_executable pvm_executable_base sysMan = unlines $
  ]
 
 -----------------------------------------------------------------------------
--- Complain about non-dynamic flags in OPTIONS pragmas
-
-checkProcessArgsResult :: [String] -> FilePath -> IO ()
-checkProcessArgsResult flags filename
-  = do when (notNull flags) (throwDyn (ProgramError (
-         showSDoc (hang (text filename <> char ':')
-                     4 (text "unknown flags in  {-# OPTIONS #-} pragma:" <+>
-                         hsep (map text flags)))
-       )))
-
------------------------------------------------------------------------------
 -- Look for the /* GHC_PACKAGES ... */ comment at the top of a .hc file
 
 getHCFilePackages :: FilePath -> IO [PackageId]
index a629ef2..f08b613 100644 (file)
@@ -239,7 +239,7 @@ import CoreSyn
 import TidyPgm
 import DriverPipeline
 import DriverPhases    ( HscSource(..), Phase(..), isHaskellSrcFilename, startPhase )
-import HeaderInfo      ( getImports, getOptions )
+import HeaderInfo
 import Finder
 import HscMain
 import HscTypes
@@ -1935,8 +1935,8 @@ preprocessFile hsc_env src_fn mb_phase (Just (buf, _time))
        let 
            local_opts = getOptions dflags buf src_fn
        --
-       (dflags', _errs, warns) <- parseDynamicFlags dflags (map unLoc local_opts)
-        -- XXX: shouldn't we be reporting the errors?
+       (dflags', leftovers, warns) <- parseDynamicFlags dflags (map unLoc local_opts)
+        checkProcessArgsResult leftovers src_fn
         handleFlagWarnings dflags' warns
 
        let
index 9b92308..10f714b 100644 (file)
@@ -17,7 +17,8 @@
 
 module HeaderInfo ( getImports
                   , getOptionsFromFile, getOptions
-                  , optionsErrorMsgs ) where
+                  , optionsErrorMsgs,
+                    checkProcessArgsResult ) where
 
 #include "HsVersions.h"
 
@@ -186,6 +187,19 @@ getOptions' dflags buf filename
                            POk state' t -> (buffer state,t):lexAll state'
                            _ -> [(buffer state,L (last_loc state) ITeof)]
 
+-----------------------------------------------------------------------------
+-- Complain about non-dynamic flags in OPTIONS pragmas
+
+checkProcessArgsResult :: [String] -> FilePath -> IO ()
+checkProcessArgsResult flags filename
+  = do when (notNull flags) (throwDyn (ProgramError (
+          showSDoc (hang (text filename <> char ':')
+                      4 (text "unknown flags in  {-# OPTIONS #-} pragma:" <+>
+                          hsep (map text flags)))
+        )))
+
+-----------------------------------------------------------------------------
+
 checkExtension :: Located FastString -> Located String
 checkExtension (L l ext)
 -- Checks if a given extension is valid, and if so returns