Commit a5061a96 authored by rpglover64's avatar rpglover64 Committed by Thomas Miedema
Browse files

Check options before warning about source imports.

Summary: Fixes T10637

Reviewers: austin, bgamari, thomie

Subscribers: dfordivam, simonpj, thomie

Differential Revision:

GHC Trac Issues: #10637
parent a1c008b3
......@@ -1544,7 +1544,8 @@ nodeMapElts = Map.elems
warnUnnecessarySourceImports :: GhcMonad m => [SCC ModSummary] -> m ()
warnUnnecessarySourceImports sccs = do
dflags <- getDynFlags
logWarnings (listToBag (concatMap (check dflags . flattenSCC) sccs))
when (wopt Opt_WarnUnusedImports dflags)
(logWarnings (listToBag (concatMap (check dflags . flattenSCC) sccs)))
where check dflags ms =
let mods_in_this_cycle = map ms_mod_name ms in
[ warn dflags i | m <- ms, i <- ms_home_srcimps m,
B.hs:5:23: Warning: {-# SOURCE #-} unnecessary in import of ‘A’
Warning: {-# SOURCE #-} unnecessary in import of ‘GHC.Unicode’
include $(TOP)/mk/
include $(TOP)/mk/
module T10637 where
import {-# SOURCE #-} A ()
data B = B
warning: {-# SOURCE #-} unnecessary in import of ‘A’
test('T10637', extra_clean(['T10637.o','T10637.hi', 'A.hi', 'A.o', 'A.hi-boot', 'A.o-boot']),
multimod_compile, ['T10637', '-v0 -fwarn-unused-imports'])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment