diff --git a/compiler/GHC/Driver/Errors/Ppr.hs b/compiler/GHC/Driver/Errors/Ppr.hs index 1fa3f5bad7138960add24e594d258d21a36cc1d4..f2e8fac6f4b8c1a64682bf80d99f190b29b07a98 100644 --- a/compiler/GHC/Driver/Errors/Ppr.hs +++ b/compiler/GHC/Driver/Errors/Ppr.hs @@ -294,7 +294,7 @@ instance Diagnostic DriverMessage where -> ErrorWithoutFlag DriverInterfaceError reason -> diagnosticReason reason DriverInconsistentDynFlags {} - -> WarningWithoutFlag + -> WarningWithFlag Opt_WarnInconsistentFlags DriverSafeHaskellIgnoredExtension {} -> WarningWithoutFlag DriverPackageTrustIgnored {} diff --git a/compiler/GHC/Driver/Flags.hs b/compiler/GHC/Driver/Flags.hs index 8a00f0b0cc5bf99a9ff89aefbd3303e54fb470e8..d9a335f8c36a6559ec2d4d6d48ae6aee00238107 100644 --- a/compiler/GHC/Driver/Flags.hs +++ b/compiler/GHC/Driver/Flags.hs @@ -650,6 +650,7 @@ data WarningFlag = | Opt_WarnMissingRoleAnnotations -- Since 9.8 | Opt_WarnImplicitRhsQuantification -- Since 9.8 | Opt_WarnIncompleteExportWarnings -- Since 9.8 + | Opt_WarnInconsistentFlags -- Since 9.8 deriving (Eq, Ord, Show, Enum) -- | Return the names of a WarningFlag @@ -760,6 +761,7 @@ warnFlagNames wflag = case wflag of Opt_WarnMissingRoleAnnotations -> "missing-role-annotations" :| [] Opt_WarnImplicitRhsQuantification -> "implicit-rhs-quantification" :| [] Opt_WarnIncompleteExportWarnings -> "incomplete-export-warnings" :| [] + Opt_WarnInconsistentFlags -> "inconsistent-flags" :| [] -- ----------------------------------------------------------------------------- -- Standard sets of warning options @@ -898,7 +900,8 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnUnicodeBidirectionalFormatCharacters, Opt_WarnGADTMonoLocalBinds, Opt_WarnLoopySuperclassSolve, - Opt_WarnTypeEqualityRequiresOperators + Opt_WarnTypeEqualityRequiresOperators, + Opt_WarnInconsistentFlags ] -- | Things you get with -W diff --git a/docs/users_guide/9.8.1-notes.rst b/docs/users_guide/9.8.1-notes.rst index dab80a070d41baf0fcf87d27d923ab82732ea086..2f1025260bff3d7af6fa2d67802e3d57a0b83b1c 100644 --- a/docs/users_guide/9.8.1-notes.rst +++ b/docs/users_guide/9.8.1-notes.rst @@ -208,6 +208,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 ~~~~ diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst index 37ae36ae50a551b4cad78d17fefeb26763228e34..bcf1068bcbe4b23c8bcb24a79cfb56e4c79df53c 100644 --- a/docs/users_guide/using-warnings.rst +++ b/docs/users_guide/using-warnings.rst @@ -78,6 +78,7 @@ 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:`-Winconsistent-flags` .. ghc-flag:: -W :shortdesc: enable normal warnings @@ -2426,7 +2427,7 @@ of ``-W(no-)*``. :reverse: -Wno-role-annotations-signatures :category: - :since: 9.8 + :since: 9.8.1 :default: off .. index:: @@ -2448,7 +2449,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 @@ -2465,9 +2466,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 @@ -2496,5 +2494,23 @@ sanity, not yours.) ) import A - When :ghc-flag:`-Wincomplete-export-warnings` is enabled, GHC warns about exports - that are not deprecating a name that is deprecated with another export in that module. \ No newline at end of file + When :ghc-flag:`-Wincomplete-export-warnings` is enabled, GHC warns about exports + that are not deprecating a name that is deprecated with another export in that module. + +.. 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.) diff --git a/testsuite/tests/driver/T20436/T20436.stderr b/testsuite/tests/driver/T20436/T20436.stderr index 66b0af04c641890611f8de5d6405971759126671..85ac12692dbc41fe8ea00738e169a9be3e5e7463 100644 --- a/testsuite/tests/driver/T20436/T20436.stderr +++ b/testsuite/tests/driver/T20436/T20436.stderr @@ -1,3 +1,3 @@ -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 diff --git a/testsuite/tests/ghc-api/T10052/T10052.stderr b/testsuite/tests/ghc-api/T10052/T10052.stderr index 15864131c5cbf2d0380f974d6aa6ad7b8730af41..25e477d991292a1edb6ffa29c595daf20f1eee39 100644 --- a/testsuite/tests/ghc-api/T10052/T10052.stderr +++ b/testsuite/tests/ghc-api/T10052/T10052.stderr @@ -1,3 +1,3 @@ -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. diff --git a/testsuite/tests/ghci/should_fail/T10549.stderr b/testsuite/tests/ghci/should_fail/T10549.stderr index 8ce1e6cadf74523ec561f34448ef3f52090295bd..69f80c898042401b7f9a3c137f8968311937a0d9 100644 --- a/testsuite/tests/ghci/should_fail/T10549.stderr +++ b/testsuite/tests/ghci/should_fail/T10549.stderr @@ -1,2 +1,3 @@ -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. diff --git a/testsuite/tests/th/T8333.stderr b/testsuite/tests/th/T8333.stderr index 15864131c5cbf2d0380f974d6aa6ad7b8730af41..69f80c898042401b7f9a3c137f8968311937a0d9 100644 --- a/testsuite/tests/th/T8333.stderr +++ b/testsuite/tests/th/T8333.stderr @@ -1,3 +1,3 @@ -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.