Skip to content
Snippets Groups Projects
Commit 21a906c2 authored by Matthew Pickering's avatar Matthew Pickering Committed by Krzysztof Gogolewski
Browse files

Add -Winconsistent-flags warning

The warning fires when inconsistent command line flags are passed.

For example:

* -dynamic-too and -dynamic
* -dynamic-too on windows
* -O and --interactive
* etc

This is on by default and allows users to control whether the warning is
displayed and whether it should be an error or not.

Fixes #22572
parent fc86f0e7
No related branches found
No related tags found
No related merge requests found
......@@ -294,7 +294,7 @@ instance Diagnostic DriverMessage where
-> ErrorWithoutFlag
DriverInterfaceError reason -> diagnosticReason reason
DriverInconsistentDynFlags {}
-> WarningWithoutFlag
-> WarningWithFlag Opt_WarnInconsistentFlags
DriverSafeHaskellIgnoredExtension {}
-> WarningWithoutFlag
DriverPackageTrustIgnored {}
......
......@@ -692,8 +692,9 @@ data WarningFlag =
| Opt_WarnMissingRoleAnnotations -- Since 9.8
| Opt_WarnImplicitRhsQuantification -- Since 9.8
| Opt_WarnIncompleteExportWarnings -- Since 9.8
| Opt_WarnIncompleteRecordSelectors -- Since 9.10
| Opt_WarnIncompleteRecordSelectors -- Since 9.10
| Opt_WarnBadlyStagedTypes -- Since 9.10
| Opt_WarnInconsistentFlags -- Since 9.8
deriving (Eq, Ord, Show, Enum)
-- | Return the names of a WarningFlag
......@@ -804,8 +805,9 @@ warnFlagNames wflag = case wflag of
Opt_WarnMissingRoleAnnotations -> "missing-role-annotations" :| []
Opt_WarnImplicitRhsQuantification -> "implicit-rhs-quantification" :| []
Opt_WarnIncompleteExportWarnings -> "incomplete-export-warnings" :| []
Opt_WarnIncompleteRecordSelectors -> "incomplete-record-selectors" :| []
Opt_WarnIncompleteRecordSelectors -> "incomplete-record-selectors" :| []
Opt_WarnBadlyStagedTypes -> "badly-staged-types" :| []
Opt_WarnInconsistentFlags -> "inconsistent-flags" :| []
-- -----------------------------------------------------------------------------
-- Standard sets of warning options
......@@ -945,7 +947,8 @@ standardWarnings -- see Note [Documenting warning flags]
Opt_WarnGADTMonoLocalBinds,
Opt_WarnLoopySuperclassSolve,
Opt_WarnBadlyStagedTypes,
Opt_WarnTypeEqualityRequiresOperators
Opt_WarnTypeEqualityRequiresOperators,
Opt_WarnInconsistentFlags
]
-- | Things you get with -W
......
......@@ -188,6 +188,10 @@ Compiler
by default for now whilst we consider more carefully an appropiate fix.
(See :ghc-ticket:`23469`, :ghc-ticket:`23109`, :ghc-ticket:`21229`, :ghc-ticket:`23445`)
- The warning about incompatible command line flags can now be controlled with the
:ghc-flag:`-Winconsistent-flags`. In particular this allows you to silence a warning
when using optimisation flags with :ghc-flag:`--interactive` mode.
GHCi
~~~~
......
......@@ -78,7 +78,8 @@ as ``-Wno-...`` for every individual warning in the group.
* :ghc-flag:`-Wforall-identifier`
* :ghc-flag:`-Wgadt-mono-local-binds`
* :ghc-flag:`-Wtype-equality-requires-operators`
* :ghc-flag:`-Wbadly-staged-types"
* :ghc-flag:`-Wbadly-staged-types`
* :ghc-flag:`-Winconsistent-flags`
.. ghc-flag:: -W
:shortdesc: enable normal warnings
......@@ -2461,7 +2462,7 @@ of ``-W(no-)*``.
:reverse: -Wno-role-annotations-signatures
:category:
:since: 9.8
:since: 9.8.1
:default: off
.. index::
......@@ -2483,7 +2484,7 @@ of ``-W(no-)*``.
:reverse: -Wno-implicit-rhs-quantification
:category:
:since: 9.8
:since: 9.8.1
:default: off
In accordance with `GHC Proposal #425
......@@ -2500,9 +2501,6 @@ of ``-W(no-)*``.
This warning detects code that will be affected by this breaking change.
If you're feeling really paranoid, the :ghc-flag:`-dcore-lint` option is a good choice.
It turns on heavyweight intra-pass sanity-checking within GHC. (It checks GHC's
sanity, not yours.)
.. ghc-flag:: -Wincomplete-export-warnings
:shortdesc: warn when some but not all of exports for a name are warned about
......@@ -2550,3 +2548,21 @@ sanity, not yours.)
This is badly staged program, and the ``tardy (Proxy @Int)`` won't produce
a type representation of ``Int``, but rather a local name ``a``.
.. ghc-flag:: -Winconsistent-flags
:shortdesc: warn when command line options are inconsistent in some way.
:type: dynamic
:reverse: -Wno-inconsistent-flags
:since: 9.8.1
:default: on
Warn when command line options are inconsistent in some way.
For example, when using GHCi, optimisation flags are ignored and a warning is
issued. Another example is :ghc-flag:`-dynamic` is ignored when :ghc-flag:`-dynamic-too`
is passed.
If you're feeling really paranoid, the :ghc-flag:`-dcore-lint` option is a good choice.
It turns on heavyweight intra-pass sanity-checking within GHC. (It checks GHC's
sanity, not yours.)
when making flags consistent: warning: [GHC-74335]
when making flags consistent: warning: [GHC-74335] [-Winconsistent-flags (in -Wdefault)]
-dynamic-too is ignored when using -dynamic
when making flags consistent: warning: [GHC-74335]
when making flags consistent: warning: [GHC-74335] [-Winconsistent-flags]
Ignoring optimization flags since they are experimental for the byte-code interpreter. Pass -fno-unoptimized-core-for-interpreter to enable this feature.
when making flags consistent: warning: [GHC-74335]
when making flags consistent: warning: [GHC-74335] [-Winconsistent-flags (in -Wdefault)]
Ignoring optimization flags since they are experimental for the byte-code interpreter. Pass -fno-unoptimized-core-for-interpreter to enable this feature.
when making flags consistent: warning: [GHC-74335]
when making flags consistent: warning: [GHC-74335] [-Winconsistent-flags (in -Wdefault)]
Ignoring optimization flags since they are experimental for the byte-code interpreter. Pass -fno-unoptimized-core-for-interpreter to enable this feature.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment