diff options
author | Zubin Duggal <zubin.duggal@gmail.com> | 2021-11-19 14:21:58 +0530 |
---|---|---|
committer | Zubin Duggal <zubin.duggal@gmail.com> | 2022-03-30 17:01:11 +0530 |
commit | 079be2c88032e2551c356bee273c301b29281135 (patch) | |
tree | c4dfcec53f77ea93d78563004ad3b38475b60ddb /compiler/GHC/Driver/Backpack.hs | |
parent | 21894a6318e0daffa0e34041855c3c73ad1f5b6f (diff) | |
download | haskell-wip/parse-errs.tar.gz |
Add warnings for file header pragmas that appear in the body of a module (#20385)wip/parse-errs
Once we are done parsing the header of a module to obtain the options, we
look through the rest of the tokens in order to determine if they contain any
misplaced file header pragmas that would usually be ignored, potentially
resulting in bad error messages.
The warnings are reported immediately so that later errors don't shadow
over potentially helpful warnings.
Metric Increase:
T13719
Diffstat (limited to 'compiler/GHC/Driver/Backpack.hs')
-rw-r--r-- | compiler/GHC/Driver/Backpack.hs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/GHC/Driver/Backpack.hs b/compiler/GHC/Driver/Backpack.hs index 43ced2ba13..9c67f1550b 100644 --- a/compiler/GHC/Driver/Backpack.hs +++ b/compiler/GHC/Driver/Backpack.hs @@ -97,7 +97,7 @@ doBackpack [src_filename] = do dflags0 <- getDynFlags let dflags1 = dflags0 let parser_opts1 = initParserOpts dflags1 - src_opts <- liftIO $ getOptionsFromFile parser_opts1 src_filename + (p_warns, src_opts) <- liftIO $ getOptionsFromFile parser_opts1 src_filename (dflags, unhandled_flags, warns) <- liftIO $ parseDynamicFilePragma dflags1 src_opts modifySession (hscSetFlags dflags) logger <- getLogger -- Get the logger after having set the session flags, @@ -105,6 +105,7 @@ doBackpack [src_filename] = do -- Not doing so caused #20396. -- Cribbed from: preprocessFile / GHC.Driver.Pipeline liftIO $ checkProcessArgsResult unhandled_flags + liftIO $ printOrThrowDiagnostics logger (initDiagOpts dflags) (GhcPsMessage <$> p_warns) liftIO $ handleFlagWarnings logger (initDiagOpts dflags) warns -- TODO: Preprocessing not implemented |