Commit 76c6727d authored by Ian Lynagh's avatar Ian Lynagh

Add a -fwarn-dodgy-exports flag; fixes #1911

This is used to control warnings that were previously unconditional.
parent 5c8d5090
......@@ -186,6 +186,7 @@ data DynFlag
| Opt_WarnUnusedMatches
| Opt_WarnWarningsDeprecations
| Opt_WarnDeprecatedFlags
| Opt_WarnDodgyExports
| Opt_WarnDodgyImports
| Opt_WarnOrphans
| Opt_WarnTabs
......@@ -931,6 +932,7 @@ minusWOpts
Opt_WarnUnusedMatches,
Opt_WarnUnusedImports,
Opt_WarnIncompletePatterns,
Opt_WarnDodgyExports,
Opt_WarnDodgyImports
]
......@@ -1652,6 +1654,7 @@ useInstead flag turn_on
fFlags :: [(String, DynFlag, Bool -> Deprecated)]
fFlags = [
( "warn-dodgy-foreign-imports", Opt_WarnDodgyForeignImports, const Supported ),
( "warn-dodgy-exports", Opt_WarnDodgyExports, const Supported ),
( "warn-dodgy-imports", Opt_WarnDodgyImports, const Supported ),
( "warn-duplicate-exports", Opt_WarnDuplicateExports, const Supported ),
( "warn-hi-shadowing", Opt_WarnHiShadows, const Supported ),
......
......@@ -893,6 +893,7 @@ exports_from_avail (Just rdr_items) rdr_env imports this_mod
| otherwise
= do { implicit_prelude <- doptM Opt_ImplicitPrelude
; warnDodgyExports <- doptM Opt_WarnDodgyExports
; let { exportValid = (mod `elem` imported_modules)
|| (moduleName this_mod == mod)
; gres = filter (isModuleExported implicit_prelude mod)
......@@ -901,7 +902,7 @@ exports_from_avail (Just rdr_items) rdr_env imports this_mod
}
; checkErr exportValid (moduleNotImported mod)
; warnIf (exportValid && null gres) (nullModuleExport mod)
; warnIf (warnDodgyExports && exportValid && null gres) (nullModuleExport mod)
; addUsedRdrNames (concat [ [mkRdrQual mod occ, mkRdrUnqual occ]
| occ <- map nameOccName names ])
......@@ -955,12 +956,14 @@ exports_from_avail (Just rdr_items) rdr_env imports this_mod
Nothing -> mkRdrUnqual
Just (modName, _) -> mkRdrQual modName
addUsedRdrNames $ map (mkKidRdrName . nameOccName) kids
when (null kids)
(if (isTyConName name) then addWarn (dodgyExportWarn name)
-- This occurs when you export T(..), but
-- only import T abstractly, or T is a synonym.
else addErr (exportItemErr ie))
warnDodgyExports <- doptM Opt_WarnDodgyExports
when (null kids) $
if isTyConName name
then when warnDodgyExports $ addWarn (dodgyExportWarn name)
else -- This occurs when you export T(..), but
-- only import T abstractly, or T is a synonym.
addErr (exportItemErr ie)
return (IEThingAll name, AvailTC name (name:kids))
lookup_ie ie@(IEThingWith rdr sub_rdrs)
......
......@@ -860,6 +860,7 @@ ghc -c Foo.hs</screen>
<indexterm><primary>-W option</primary></indexterm>
<para>Provides the standard warnings plus
<option>-fwarn-incomplete-patterns</option>,
<option>-fwarn-dodgy-exports</option>,
<option>-fwarn-dodgy-imports</option>,
<option>-fwarn-unused-matches</option>,
<option>-fwarn-unused-imports</option>, and
......@@ -990,6 +991,20 @@ foreign import "&amp;f" f :: FunPtr t
</listitem>
</varlistentry>
<varlistentry>
<term><option>-fwarn-dodgy-exports</option>:</term>
<listitem>
<indexterm><primary><option>-fwarn-dodgy-exports</option></primary>
</indexterm>
<para>Causes a warning to be emitted when a datatype
<literal>T</literal> is exported
with all constructors, i.e. <literal>T(..)</literal>, but is it
just a type synonym.</para>
<para>Also causes a warning to be emitted when a module is
re-exported, but that module exports nothing.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-fwarn-dodgy-imports</option>:</term>
<listitem>
......
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