Commit a5061a96 authored by rpglover64's avatar rpglover64 Committed by thomie

Check options before warning about source imports.

Summary: Fixes T10637

Reviewers: austin, bgamari, thomie

Subscribers: dfordivam, simonpj, thomie

Differential Revision: https://phabricator.haskell.org/D1157

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’
GHC/Word.hs:10:23:
Warning: {-# SOURCE #-} unnecessary in import of ‘GHC.Unicode’
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
module T10637 where
import {-# SOURCE #-} A ()
data B = B
T10637.hs:3:23:
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'])
Markdown is supported
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