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 /compiler | |
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 'compiler')
-rw-r--r-- | compiler/main/DynFlags.hs | 2 | ||||
-rw-r--r-- | compiler/main/SysTools.hs | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 7978c03352..cd8dc41ceb 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -619,6 +619,7 @@ data WarningFlag = | Opt_WarnMissingPatternSynonymSignatures -- since 8.0 | Opt_WarnUnrecognisedWarningFlags -- since 8.0 | Opt_WarnSimplifiableClassConstraints -- Since 8.2 + | Opt_WarnCPPUndef -- Since 8.2 deriving (Eq, Show, Enum) data Language = Haskell98 | Haskell2010 @@ -3287,6 +3288,7 @@ wWarningFlagsDeps = [ "it has no effect", depFlagSpec "auto-orphans" Opt_WarnAutoOrphans "it has no effect", + flagSpec "cpp-undef" Opt_WarnCPPUndef, flagSpec "deferred-type-errors" Opt_WarnDeferredTypeErrors, flagSpec "deferred-out-of-scope-variables" Opt_WarnDeferredOutOfScopeVariables, diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs index dd98883cb5..d5fd0c5c29 100644 --- a/compiler/main/SysTools.hs +++ b/compiler/main/SysTools.hs @@ -403,9 +403,8 @@ runCpp :: DynFlags -> [Option] -> IO () runCpp dflags args = do let (p,args0) = pgm_P dflags args1 = map Option (getOpts dflags opt_P) - args2 = if gopt Opt_WarnIsError dflags - then [Option "-Werror"] - else [] + args2 = [Option "-Werror" | gopt Opt_WarnIsError dflags] + ++ [Option "-Wundef" | wopt Opt_WarnCPPUndef dflags] mb_env <- getGccEnv args2 runSomethingFiltered dflags id "C pre-processor" p (args0 ++ args1 ++ args2 ++ args) mb_env |