Commit 972ba121 authored by mlen's avatar mlen Committed by Austin Seipp

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
parent 69f63612
......@@ -3073,7 +3073,8 @@ standardWarnings
Opt_WarnInlineRuleShadowing,
Opt_WarnAlternativeLayoutRuleTransitional,
Opt_WarnUnsupportedLlvmVersion,
Opt_WarnContextQuantification
Opt_WarnContextQuantification,
Opt_WarnTabs
]
minusWOpts :: [WarningFlag]
......
......@@ -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>
......
......@@ -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
......@@ -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:
......
......@@ -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)" ""
......
......@@ -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, [''])
......
......@@ -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'])
......
......@@ -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']),
......
module T9230 where
test :: Monad m => m ()
test = do
return ()
T9230.hs:5:1: Warning: Tab character
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'), [''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment