summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Rozenshteyn <rpglover64@gmail.com>2015-08-21 21:42:16 +0200
committerThomas Miedema <thomasmiedema@gmail.com>2015-08-22 00:00:55 +0200
commita5061a96724922097e4181d452a64618e35fa297 (patch)
treea2ad14d0f2ad59b968d2fc140a7e90ba89d0386a
parenta1c008b30fc60a327afe098cf16bd14ca1e5e381 (diff)
downloadhaskell-a5061a96724922097e4181d452a64618e35fa297.tar.gz
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
-rw-r--r--compiler/main/GhcMake.hs3
-rw-r--r--testsuite/tests/programs/hs-boot/hs-boot.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/T3103/T3103.stderr3
-rw-r--r--testsuite/tests/warnings/should_compile/T10637/A.hs3
-rw-r--r--testsuite/tests/warnings/should_compile/T10637/A.hs-boot1
-rw-r--r--testsuite/tests/warnings/should_compile/T10637/Makefile3
-rw-r--r--testsuite/tests/warnings/should_compile/T10637/T10637.hs4
-rw-r--r--testsuite/tests/warnings/should_compile/T10637/T10637.stderr3
-rw-r--r--testsuite/tests/warnings/should_compile/T10637/all.T2
9 files changed, 18 insertions, 6 deletions
diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
index 7c3f95b44f..ba21e5b941 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 42ca073117..e69de29bb2 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 f1d4c531fa..e69de29bb2 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/warnings/should_compile/T10637/A.hs b/testsuite/tests/warnings/should_compile/T10637/A.hs
new file mode 100644
index 0000000000..a5369fccc6
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T10637/A.hs
@@ -0,0 +1,3 @@
+module A where
+
+data A = A
diff --git a/testsuite/tests/warnings/should_compile/T10637/A.hs-boot b/testsuite/tests/warnings/should_compile/T10637/A.hs-boot
new file mode 100644
index 0000000000..d843c00b78
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T10637/A.hs-boot
@@ -0,0 +1 @@
+module A where
diff --git a/testsuite/tests/warnings/should_compile/T10637/Makefile b/testsuite/tests/warnings/should_compile/T10637/Makefile
new file mode 100644
index 0000000000..1c39d1c1fe
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T10637/Makefile
@@ -0,0 +1,3 @@
+TOP=../../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
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 0000000000..03a1e789ba
--- /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 0000000000..0778bed810
--- /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 0000000000..2be9756fae
--- /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'])