summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Lenik <mlen@mlen.pl>2014-10-21 15:34:00 -0500
committerAustin Seipp <austin@well-typed.com>2014-10-21 15:36:14 -0500
commit972ba1210d1bb535c41526ce396c0f086d30b59a (patch)
treea6b4531b00c8cfa98ef0e12ecbbbfc181abffbc7
parent69f63612fc17cd6b3baaa8898c8595bde304ebfb (diff)
downloadhaskell-972ba1210d1bb535c41526ce396c0f086d30b59a.tar.gz
Enabled warn on tabs by default (fixes #9230)
Summary: This revision enables -fwarn-tabs by default and add a suppression flag, so that GHC compilation won't fail when some files contain tab characters. Test Plan: Additional test case, T9230, was added to cover that change. Reviewers: austin Reviewed By: austin Subscribers: simonmar, ezyang, carter, thomie, mlen Differential Revision: https://phabricator.haskell.org/D255 GHC Trac Issues: #9230 Conflicts: testsuite/driver/testlib.py
-rw-r--r--compiler/main/DynFlags.hs3
-rw-r--r--docs/users_guide/7.10.1-notes.xml6
-rw-r--r--mk/validate-settings.mk9
-rw-r--r--testsuite/driver/testlib.py62
-rw-r--r--testsuite/mk/test.mk8
-rw-r--r--testsuite/tests/deSugar/should_compile/all.T4
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T2
-rw-r--r--testsuite/tests/module/all.T2
-rw-r--r--testsuite/tests/warnings/should_compile/T9230.hs5
-rw-r--r--testsuite/tests/warnings/should_compile/T9230.stderr2
-rw-r--r--testsuite/tests/warnings/should_compile/all.T3
11 files changed, 93 insertions, 13 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 7ae04ee1ea..3b2ab47de3 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -3073,7 +3073,8 @@ standardWarnings
Opt_WarnInlineRuleShadowing,
Opt_WarnAlternativeLayoutRuleTransitional,
Opt_WarnUnsupportedLlvmVersion,
- Opt_WarnContextQuantification
+ Opt_WarnContextQuantification,
+ Opt_WarnTabs
]
minusWOpts :: [WarningFlag]
diff --git a/docs/users_guide/7.10.1-notes.xml b/docs/users_guide/7.10.1-notes.xml
index 7b4000202c..3ca5112a9f 100644
--- a/docs/users_guide/7.10.1-notes.xml
+++ b/docs/users_guide/7.10.1-notes.xml
@@ -87,6 +87,12 @@
<option>-XTypeFamilies</option>, <option>-XGADTs</option> or
<option>-XFlexibleContexts</option>).
</para>
+ <para>
+ <option>-fwarn-tabs</option> warning flag is turned on by
+ default with this release of GHC. It can be suppressed
+ either by using <literal>GHC_OPTIONS</literal> pragma or by
+ specifying <option>-fno-warn-tabs</option> flag.
+ </para>
</listitem>
</itemizedlist>
</sect3>
diff --git a/mk/validate-settings.mk b/mk/validate-settings.mk
index 734e28de7b..b05b289239 100644
--- a/mk/validate-settings.mk
+++ b/mk/validate-settings.mk
@@ -167,3 +167,12 @@ libraries/template-haskell_dist-install_EXTRA_HC_OPTS += -fno-warn-inline-rule-s
# We need -fno-warn-deprecated-flags to avoid failure with -Werror
GhcLibHcOpts += -fno-warn-deprecated-flags
GhcBootLibHcOpts += -fno-warn-deprecated-flags
+
+# The warning suppression flag below is a temporary kludge. While working with
+# modules that contain tabs, please de-tab them so this flag can be eventually
+# removed. See
+# http://ghc.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces
+# for details
+#
+GhcLibHcOpts += -fno-warn-tabs
+utils/hsc2hs_dist-install_EXTRA_HC_OPTS += -fno-warn-tabs
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 93b18a8614..19fd0f8056 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -890,11 +890,29 @@ def run_command( name, way, cmd ):
# -----------------------------------------------------------------------------
# GHCi tests
-def ghci_script( name, way, script ):
+def ghci_script_without_flag(flag):
+ def apply(name, way, script):
+ overrides = filter(lambda f: f != flag, getTestOpts().compiler_always_flags)
+ return ghci_script_override_default_flags(overrides)(name, way, script)
+
+ return apply
+
+def ghci_script_override_default_flags(overrides):
+ def apply(name, way, script):
+ return ghci_script(name, way, script, overrides)
+
+ return apply
+
+def ghci_script( name, way, script, override_flags = None ):
+ # Use overriden default flags when given
+ if override_flags:
+ default_flags = override_flags
+ else:
+ default_flags = getTestOpts().compiler_always_flags
+
# filter out -fforce-recomp from compiler_always_flags, because we're
# actually testing the recompilation behaviour in the GHCi tests.
- flags = [f for f in getTestOpts().compiler_always_flags if f != '-fforce-recomp']
-
+ flags = [f for f in default_flags if f != '-fforce-recomp']
flags.append(getTestOpts().extra_hc_opts)
if getTestOpts().outputdir != None:
flags.extend(["-outputdir", getTestOpts().outputdir])
@@ -913,6 +931,32 @@ def ghci_script( name, way, script ):
# -----------------------------------------------------------------------------
# Compile-only tests
+def compile_override_default_flags(overrides):
+ def apply(name, way, extra_opts):
+ return do_compile(name, way, 0, '', [], extra_opts, overrides)
+
+ return apply
+
+def compile_fail_override_default_flags(overrides):
+ def apply(name, way, extra_opts):
+ return do_compile(name, way, 1, '', [], extra_opts, overrides)
+
+ return apply
+
+def compile_without_flag(flag):
+ def apply(name, way, extra_opts):
+ overrides = filter(lambda f: f != flag, getTestOpts().compiler_always_flags)
+ return compile_override_default_flags(overrides)(name, way, extra_opts)
+
+ return apply
+
+def compile_fail_without_flag(flag):
+ def apply(name, way, extra_opts):
+ overrides = filter(lambda f: f != flag, getTestOpts().compiler_always_flags)
+ return compile_fail_override_default_flags(overrides)(name, way, extra_opts)
+
+ return apply
+
def compile( name, way, extra_hc_opts ):
return do_compile( name, way, 0, '', [], extra_hc_opts )
@@ -931,7 +975,7 @@ def multi_compile( name, way, top_mod, extra_mods, extra_hc_opts ):
def multi_compile_fail( name, way, top_mod, extra_mods, extra_hc_opts ):
return do_compile( name, way, 1, top_mod, extra_mods, extra_hc_opts)
-def do_compile( name, way, should_fail, top_mod, extra_mods, extra_hc_opts ):
+def do_compile( name, way, should_fail, top_mod, extra_mods, extra_hc_opts, override_flags = None ):
# print 'Compile only, extra args = ', extra_hc_opts
pretest_cleanup(name)
@@ -943,7 +987,7 @@ def do_compile( name, way, should_fail, top_mod, extra_mods, extra_hc_opts ):
force = 0
if extra_mods:
force = 1
- result = simple_build( name, way, extra_hc_opts, should_fail, top_mod, 0, 1, force)
+ result = simple_build( name, way, extra_hc_opts, should_fail, top_mod, 0, 1, force, override_flags )
if badResult(result):
return result
@@ -1103,7 +1147,7 @@ def extras_build( way, extra_mods, extra_hc_opts ):
return {'passFail' : 'pass', 'hc_opts' : extra_hc_opts}
-def simple_build( name, way, extra_hc_opts, should_fail, top_mod, link, addsuf, noforce ):
+def simple_build( name, way, extra_hc_opts, should_fail, top_mod, link, addsuf, noforce, override_flags = None ):
opts = getTestOpts()
errname = add_suffix(name, 'comp.stderr')
rm_no_fail( qualify(errname, '') )
@@ -1151,7 +1195,11 @@ def simple_build( name, way, extra_hc_opts, should_fail, top_mod, link, addsuf,
else:
cmd_prefix = getTestOpts().compile_cmd_prefix + ' '
- comp_flags = copy.copy(getTestOpts().compiler_always_flags)
+ if override_flags:
+ comp_flags = copy.copy(override_flags)
+ else:
+ comp_flags = copy.copy(getTestOpts().compiler_always_flags)
+
if noforce:
comp_flags = [f for f in comp_flags if f != '-fforce-recomp']
if getTestOpts().outputdir != None:
diff --git a/testsuite/mk/test.mk b/testsuite/mk/test.mk
index 2ff8616eba..0229cfd5b3 100644
--- a/testsuite/mk/test.mk
+++ b/testsuite/mk/test.mk
@@ -36,6 +36,14 @@ endif
# in nested Makefiles
TEST_HC_OPTS = -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-$(GhcPackageDbFlag) -rtsopts $(EXTRA_HC_OPTS)
+# The warning suppression flag below is a temporary kludge. While working with
+# tests that contain tabs, please de-tab them so this flag can be eventually
+# removed. See
+# http://ghc.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces
+# for details
+#
+TEST_HC_OPTS += -fno-warn-tabs
+
RUNTEST_OPTS =
ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
diff --git a/testsuite/tests/deSugar/should_compile/all.T b/testsuite/tests/deSugar/should_compile/all.T
index ac748d3ae4..ac8f95c0c2 100644
--- a/testsuite/tests/deSugar/should_compile/all.T
+++ b/testsuite/tests/deSugar/should_compile/all.T
@@ -59,9 +59,9 @@ test('ds052', normal, compile, [''])
test('ds053', normal, compile, [''])
test('ds054', normal, compile, [''])
test('ds055', only_compiler_types(['ghc']), compile, [''])
-test('ds056', normal, compile, ['-Wall'])
+test('ds056', normal, compile, ['-Wall -fno-warn-tabs'])
test('ds057', normal, compile, [''])
-test('ds058', normal, compile, ['-W'])
+test('ds058', normal, compile, ['-W -fno-warn-tabs'])
test('ds059', normal, compile, ['-W'])
test('ds060', expect_broken(322), compile, [''])
test('ds062', normal, compile, [''])
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 4b20d0b3e3..1c8adeb6d0 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -82,7 +82,7 @@ test('ghci056',
],
ghci_script, ['ghci056.script'])
-test('ghci057', normal, ghci_script, ['ghci057.script'])
+test('ghci057', normal, ghci_script_without_flag('-fno-warn-tabs'), ['ghci057.script'])
test('T2452', normal, ghci_script, ['T2452.script'])
test('T2766', normal, ghci_script, ['T2766.script'])
diff --git a/testsuite/tests/module/all.T b/testsuite/tests/module/all.T
index cb5ce2fe8d..c91d30c7b4 100644
--- a/testsuite/tests/module/all.T
+++ b/testsuite/tests/module/all.T
@@ -309,7 +309,7 @@ test('mod170', extra_clean(['Mod170_A.hi', 'Mod170_A.o']),
test('mod171', extra_clean(['Mod171_A.hi', 'Mod171_A.o', 'Mod171_B.hi', 'Mod171_B.o']),
- multimod_compile, ['mod171', '-v0 -Wall'])
+ multimod_compile, ['mod171', '-v0 -Wall -fno-warn-tabs'])
test('mod172', extra_clean(['Mod172_B.hi', 'Mod172_B.o', 'Mod172_C.hi', 'Mod172_C.o']),
diff --git a/testsuite/tests/warnings/should_compile/T9230.hs b/testsuite/tests/warnings/should_compile/T9230.hs
new file mode 100644
index 0000000000..cb369f7fea
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T9230.hs
@@ -0,0 +1,5 @@
+module T9230 where
+
+test :: Monad m => m ()
+test = do
+ return ()
diff --git a/testsuite/tests/warnings/should_compile/T9230.stderr b/testsuite/tests/warnings/should_compile/T9230.stderr
new file mode 100644
index 0000000000..09e1f647ed
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T9230.stderr
@@ -0,0 +1,2 @@
+
+T9230.hs:5:1: Warning: Tab character
diff --git a/testsuite/tests/warnings/should_compile/all.T b/testsuite/tests/warnings/should_compile/all.T
index f6747bf849..903ab69a84 100644
--- a/testsuite/tests/warnings/should_compile/all.T
+++ b/testsuite/tests/warnings/should_compile/all.T
@@ -1,3 +1,4 @@
test('T9178', extra_clean(['T9178.o', 'T9178DataType.o',
'T9178.hi', 'T9178DataType.hi']),
- multimod_compile, ['T9178', '-Wall']) \ No newline at end of file
+ multimod_compile, ['T9178', '-Wall'])
+test('T9230', normal, compile_without_flag('-fno-warn-tabs'), [''])