[commit: ghc] master: Driver: --make -o without Main should be an error (#10895) (1637e4d)
git at git.haskell.org
git at git.haskell.org
Sun Sep 20 17:42:49 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/1637e4d16d28223aac66100cf7308d76a2a7ee7c/ghc
>---------------------------------------------------------------
commit 1637e4d16d28223aac66100cf7308d76a2a7ee7c
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date: Sat Sep 19 16:14:47 2015 +0200
Driver: --make -o without Main should be an error (#10895)
Reviewed by: austin
Differential Revision: https://phabricator.haskell.org/D1253
>---------------------------------------------------------------
1637e4d16d28223aac66100cf7308d76a2a7ee7c
compiler/main/GhcMake.hs | 20 +++++++++++---------
.../should_compile => driver/should_fail}/Makefile | 0
testsuite/tests/driver/should_fail/T10895.hs | 1 +
testsuite/tests/driver/should_fail/T10895.stderr | 4 ++++
testsuite/tests/driver/should_fail/all.T | 2 ++
5 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
index ba21e5b..2ea3816 100644
--- a/compiler/main/GhcMake.hs
+++ b/compiler/main/GhcMake.hs
@@ -325,18 +325,20 @@ load how_much = do
a_root_is_Main = any ((==main_mod).ms_mod) mod_graph
do_linking = a_root_is_Main || no_hs_main || ghcLink dflags == LinkDynLib || ghcLink dflags == LinkStaticLib
- when (ghcLink dflags == LinkBinary
- && isJust ofile && not do_linking) $
- liftIO $ debugTraceMsg dflags 1 $
- text ("Warning: output was redirected with -o, " ++
- "but no output will be generated\n" ++
- "because there is no " ++
- moduleNameString (moduleName main_mod) ++ " module.")
-
-- link everything together
linkresult <- liftIO $ link (ghcLink dflags) dflags do_linking (hsc_HPT hsc_env1)
- loadFinish Succeeded linkresult
+ if ghcLink dflags == LinkBinary && isJust ofile && not do_linking
+ then do
+ liftIO $ errorMsg dflags $ text
+ ("output was redirected with -o, " ++
+ "but no output will be generated\n" ++
+ "because there is no " ++
+ moduleNameString (moduleName main_mod) ++ " module.")
+ -- This should be an error, not a warning (#10895).
+ loadFinish Failed linkresult
+ else
+ loadFinish Succeeded linkresult
else
-- Tricky. We need to back out the effects of compiling any
diff --git a/testsuite/tests/annotations/should_compile/Makefile b/testsuite/tests/driver/should_fail/Makefile
similarity index 100%
copy from testsuite/tests/annotations/should_compile/Makefile
copy to testsuite/tests/driver/should_fail/Makefile
diff --git a/testsuite/tests/driver/should_fail/T10895.hs b/testsuite/tests/driver/should_fail/T10895.hs
new file mode 100644
index 0000000..91faa50
--- /dev/null
+++ b/testsuite/tests/driver/should_fail/T10895.hs
@@ -0,0 +1 @@
+module NotMain where
diff --git a/testsuite/tests/driver/should_fail/T10895.stderr b/testsuite/tests/driver/should_fail/T10895.stderr
new file mode 100644
index 0000000..3ae52a3
--- /dev/null
+++ b/testsuite/tests/driver/should_fail/T10895.stderr
@@ -0,0 +1,4 @@
+
+<no location info>: error:
+ output was redirected with -o, but no output will be generated
+because there is no Main module.
diff --git a/testsuite/tests/driver/should_fail/all.T b/testsuite/tests/driver/should_fail/all.T
new file mode 100644
index 0000000..f068d65
--- /dev/null
+++ b/testsuite/tests/driver/should_fail/all.T
@@ -0,0 +1,2 @@
+# --make -o without Main should be an error, not a warning.
+test('T10895', normal, multimod_compile_fail, ['T10895.hs', '-v0 -o dummy'])
More information about the ghc-commits
mailing list