Skip to content

Make unrecognised `-W` flags a warning rather than an error

Currently, it's a fatal error to pass GHC a warning flag it doesn't recognise:

$ ghc-8.1.20160111 -Wfoobar -c foobar.hs
ghc: unrecognised flag: -Wfoobar

Usage: For basic information, try the `--help' option.

However, in order to gain more flexibility adding/removing warning flags without requiring users to carefully guard which flags a given GHC version supports, it was suggested to make GHC more tolerating in case of unrecognised warning flags (which may either have been removed, or not yet available in the current GHC version).

Specifically, I propose the following:

  1. Handle -Wno-<token> or -W<token> for an unknown <token> as a warning rather than an error
  2. This warning gets its own token unrecognised-warning-flag (turned on by default), so that it can be controlled via the general warning facilities as well:
  • -Wno-unrecognised-warning-flag turns off such warnings

  • -Wunrecognised-warning-flag turns on such warnings explicitly

  • -Werror=unrecognised-warning-flag (once we have #11219 (closed)) emulates the old behaviour

  • various other combinations with warning-sets, -Werror specifications
Trac metadata
Trac field Value
Version
Type FeatureRequest
TypeOfFailure OtherFailure
Priority highest
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC bgamari, ekmett, quchen
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information