Check options before warning about source imports.
authorAlex Rozenshteyn <rpglover64@gmail.com>
Fri, 21 Aug 2015 19:42:16 +0000 (21:42 +0200)
committerThomas Miedema <thomasmiedema@gmail.com>
Fri, 21 Aug 2015 22:00:55 +0000 (00:00 +0200)
Summary: Fixes T10637

Reviewers: austin, bgamari, thomie

Subscribers: dfordivam, simonpj, thomie

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

GHC Trac Issues: #10637

compiler/main/GhcMake.hs
testsuite/tests/programs/hs-boot/hs-boot.stderr
testsuite/tests/rename/should_compile/T3103/T3103.stderr
testsuite/tests/warnings/should_compile/T10637/A.hs [new file with mode: 0644]
testsuite/tests/warnings/should_compile/T10637/A.hs-boot [new file with mode: 0644]
testsuite/tests/warnings/should_compile/T10637/Makefile [new file with mode: 0644]
testsuite/tests/warnings/should_compile/T10637/T10637.hs [new file with mode: 0644]
testsuite/tests/warnings/should_compile/T10637/T10637.stderr [new file with mode: 0644]
testsuite/tests/warnings/should_compile/T10637/all.T [new file with mode: 0644]

index 7c3f95b..ba21e5b 100644 (file)
@@ -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,
index f1d4c53..e69de29 100644 (file)
@@ -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 (file)
index 0000000..a5369fc
--- /dev/null
@@ -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 (file)
index 0000000..d843c00
--- /dev/null
@@ -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 (file)
index 0000000..1c39d1c
--- /dev/null
@@ -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 (file)
index 0000000..03a1e78
--- /dev/null
@@ -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 (file)
index 0000000..0778bed
--- /dev/null
@@ -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 (file)
index 0000000..2be9756
--- /dev/null
@@ -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'])