diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2016-10-22 15:38:41 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-10-22 15:39:50 -0400 |
commit | 3cb32d8b0b51c548ab424139c66cce6b37a2ab1b (patch) | |
tree | 5602166b4af34666bcaad61a23cd5b216a971474 /testsuite | |
parent | a662f46c32ce35bd0769aa1ab224c3dfd39e207c (diff) | |
download | haskell-3cb32d8b0b51c548ab424139c66cce6b37a2ab1b.tar.gz |
Add -Wcpp-undef warning flag
When enabled, this new warning flag passes `-Wundef` to the C
pre-processor which causes the pre-processor to warn on uses of
the `#if` directive on undefined identifiers.
It is not currently enabled in any of the standard warning groups.
Test Plan: Make sure the two tests pass on all major platforms.
Reviewers: hvr, carter, Phyx, bgamari, austin
Reviewed By: Phyx
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2626
GHC Trac Issues: #12752
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/driver/T12752pass.hs | 9 | ||||
-rw-r--r-- | testsuite/tests/driver/all.T | 4 | ||||
-rw-r--r-- | testsuite/tests/driver/should_fail/T12752.hs | 10 | ||||
-rw-r--r-- | testsuite/tests/driver/should_fail/all.T | 2 |
4 files changed, 24 insertions, 1 deletions
diff --git a/testsuite/tests/driver/T12752pass.hs b/testsuite/tests/driver/T12752pass.hs new file mode 100644 index 0000000000..5826d48b88 --- /dev/null +++ b/testsuite/tests/driver/T12752pass.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE CPP #-} + +#if SHOULD_PASS +message :: String +message = "Hello!" +#endif + +main :: IO () +main = putStrLn message diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index c6283df156..8cd5c2f968 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -491,9 +491,11 @@ test('T12135', run_command, ['$MAKE -s --no-print-directory T12135']) -test('T12192', normal, run_command, ['mkdir foo && (cd foo && {compiler} -v0 ../T12192)']) +test('T12192', normal, run_command, ['mkdir foo && (cd foo && {compiler} -v0 ../T12192)']) test('T10923', extra_clean(['T10923.o', 'T10923.hi']), run_command, ['$MAKE -s --no-print-directory T10923']) + +test('T12752pass', normal, compile, ['-DSHOULD_PASS=1 -Wcpp-undef']) diff --git a/testsuite/tests/driver/should_fail/T12752.hs b/testsuite/tests/driver/should_fail/T12752.hs new file mode 100644 index 0000000000..3560d00894 --- /dev/null +++ b/testsuite/tests/driver/should_fail/T12752.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE CPP #-} + +-- This should fail to compile with "ghc -Wcpp-undef -Werror ...". +#if this_cpp_identifier_does_not_exist +message :: String +message = "This is wrong!" +#endif + +main :: IO () +main = putStrLn "Hello" diff --git a/testsuite/tests/driver/should_fail/all.T b/testsuite/tests/driver/should_fail/all.T index f068d6516d..3d0708b285 100644 --- a/testsuite/tests/driver/should_fail/all.T +++ b/testsuite/tests/driver/should_fail/all.T @@ -1,2 +1,4 @@ # --make -o without Main should be an error, not a warning. test('T10895', normal, multimod_compile_fail, ['T10895.hs', '-v0 -o dummy']) + +test('T12752', expect_fail, compile, ['-Wcpp-undef -Werror']) |