Commit 8ec5ceb0 authored by Oleg Grenrus's avatar Oleg Grenrus Committed by Ben Gamari

Add -Wmissing-safe-haskell-mode warning

parent a863c44f
......@@ -498,6 +498,14 @@ tcRnModule' sum save_rn_syntax mod = do
hsc_env <- getHscEnv
dflags <- getDynFlags
-- -Wmissing-safe-haskell-mode
when (not (safeHaskellModeEnabled dflags)
&& wopt Opt_WarnMissingSafeHaskellMode dflags) $
logWarnings $ unitBag $
makeIntoWarning (Reason Opt_WarnMissingSafeHaskellMode) $
mkPlainWarnMsg dflags (getLoc (hpm_module mod)) $
tcg_res <- {-# SCC "Typecheck-Rename" #-}
ioMsgMaybe $
tcRnModule hsc_env sum
......@@ -544,6 +552,8 @@ tcRnModule' sum save_rn_syntax mod = do
errSafe t = quotes (pprMod t) <+> text "has been inferred as safe!"
errTwthySafe t = quotes (pprMod t)
<+> text "is marked as Trustworthy but has been inferred as safe!"
warnMissingSafeHaskellMode = ppr (moduleName (ms_mod sum))
<+> text "is missing Safe Haskell mode"
-- | Convert a typechecked module to Core
hscDesugar :: HscEnv -> ModSummary -> TcGblEnv -> IO ModGuts
......@@ -740,7 +740,7 @@ And one general flag:
requiring the package that ``M`` resides in be considered trusted, for ``M``
to be considered trusted.
And four warning flags:
And five warning flags:
.. ghc-flag:: -Wunsafe
:shortdesc: warn if the module being compiled is regarded to be unsafe.
......@@ -809,6 +809,22 @@ And four warning flags:
``B``, it will cause compilation error of ``A``. When
:ghc-flag:`-Winferred-safe-imports` is enabled, the compiler will emit a
warning about this.
This option is off by default.
.. ghc-flag:: -Wmissing-safe-haskell-mode
:shortdesc: warn when the Safe Haskell mode is not explicitly specified.
:type: dynamic
:reverse: -Wno-missing-safe-haskell-mode
:since: 8.10.1
.. index::
single: safe haskell mode, missing
The compiler will warn when none of :extension:`Safe`,
:extension:`Trustworthy` or :extension:`Unsafe` is specified.
This option is off by default.
.. _safe-compilation:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment