[commit: ghc] master: Check options before warning about source imports. (a5061a9)
git at git.haskell.org
git at git.haskell.org
Fri Aug 21 22:01:51 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/a5061a96724922097e4181d452a64618e35fa297/ghc
>---------------------------------------------------------------
commit a5061a96724922097e4181d452a64618e35fa297
Author: Alex Rozenshteyn <rpglover64 at gmail.com>
Date: Fri Aug 21 21:42:16 2015 +0200
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
>---------------------------------------------------------------
a5061a96724922097e4181d452a64618e35fa297
compiler/main/GhcMake.hs | 3 ++-
testsuite/tests/programs/hs-boot/hs-boot.stderr | 2 --
testsuite/tests/rename/should_compile/T3103/T3103.stderr | 3 ---
.../tests/{ghci/prog009/A1.hs => warnings/should_compile/T10637/A.hs} | 2 +-
.../tests/{th/T2014 => warnings/should_compile/T10637}/A.hs-boot | 0
.../scripts/break022 => warnings/should_compile/T10637}/Makefile | 0
testsuite/tests/warnings/should_compile/T10637/T10637.hs | 4 ++++
testsuite/tests/warnings/should_compile/T10637/T10637.stderr | 3 +++
testsuite/tests/warnings/should_compile/T10637/all.T | 2 ++
9 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
index 7c3f95b..ba21e5b 100644
--- a/compiler/main/GhcMake.hs
+++ b/compiler/main/GhcMake.hs
@@ -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,
diff --git a/testsuite/tests/programs/hs-boot/hs-boot.stderr b/testsuite/tests/programs/hs-boot/hs-boot.stderr
index 42ca073..e69de29 100644
--- a/testsuite/tests/programs/hs-boot/hs-boot.stderr
+++ b/testsuite/tests/programs/hs-boot/hs-boot.stderr
@@ -1,2 +0,0 @@
-
-B.hs:5:23: Warning: {-# SOURCE #-} unnecessary in import of ‘A’
diff --git a/testsuite/tests/rename/should_compile/T3103/T3103.stderr b/testsuite/tests/rename/should_compile/T3103/T3103.stderr
index f1d4c53..e69de29 100644
--- a/testsuite/tests/rename/should_compile/T3103/T3103.stderr
+++ b/testsuite/tests/rename/should_compile/T3103/T3103.stderr
@@ -1,3 +0,0 @@
-
-GHC/Word.hs:10:23:
- Warning: {-# SOURCE #-} unnecessary in import of ‘GHC.Unicode’
diff --git a/testsuite/tests/ghci/prog009/A1.hs b/testsuite/tests/warnings/should_compile/T10637/A.hs
similarity index 59%
copy from testsuite/tests/ghci/prog009/A1.hs
copy to testsuite/tests/warnings/should_compile/T10637/A.hs
index 41644a1..a5369fc 100644
--- a/testsuite/tests/ghci/prog009/A1.hs
+++ b/testsuite/tests/warnings/should_compile/T10637/A.hs
@@ -1,3 +1,3 @@
module A where
-import B
+data A = A
diff --git a/testsuite/tests/th/T2014/A.hs-boot b/testsuite/tests/warnings/should_compile/T10637/A.hs-boot
similarity index 100%
copy from testsuite/tests/th/T2014/A.hs-boot
copy to testsuite/tests/warnings/should_compile/T10637/A.hs-boot
diff --git a/testsuite/tests/ghci.debugger/scripts/break022/Makefile b/testsuite/tests/warnings/should_compile/T10637/Makefile
similarity index 100%
copy from testsuite/tests/ghci.debugger/scripts/break022/Makefile
copy to testsuite/tests/warnings/should_compile/T10637/Makefile
diff --git a/testsuite/tests/warnings/should_compile/T10637/T10637.hs b/testsuite/tests/warnings/should_compile/T10637/T10637.hs
new file mode 100644
index 0000000..03a1e78
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T10637/T10637.hs
@@ -0,0 +1,4 @@
+module T10637 where
+
+import {-# SOURCE #-} A ()
+data B = B
diff --git a/testsuite/tests/warnings/should_compile/T10637/T10637.stderr b/testsuite/tests/warnings/should_compile/T10637/T10637.stderr
new file mode 100644
index 0000000..0778bed
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T10637/T10637.stderr
@@ -0,0 +1,3 @@
+
+T10637.hs:3:23:
+ warning: {-# SOURCE #-} unnecessary in import of ‘A’
diff --git a/testsuite/tests/warnings/should_compile/T10637/all.T b/testsuite/tests/warnings/should_compile/T10637/all.T
new file mode 100644
index 0000000..2be9756
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T10637/all.T
@@ -0,0 +1,2 @@
+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'])
More information about the ghc-commits
mailing list