From: Ian Lynagh Date: Sun, 19 Jul 2009 20:01:24 +0000 (+0000) Subject: Add a -fwarn-dodgy-exports flag; fixes #1911 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=76c6727d14fe738f4460882739dd462686b008b9 Add a -fwarn-dodgy-exports flag; fixes #1911 This is used to control warnings that were previously unconditional. --- diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index fce8eac..20ac77e 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -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 ), diff --git a/compiler/rename/RnNames.lhs b/compiler/rename/RnNames.lhs index 1052db6..63f29d9 100644 --- a/compiler/rename/RnNames.lhs +++ b/compiler/rename/RnNames.lhs @@ -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) diff --git a/docs/users_guide/using.xml b/docs/users_guide/using.xml index f668639..06b9ccc 100644 --- a/docs/users_guide/using.xml +++ b/docs/users_guide/using.xml @@ -860,6 +860,7 @@ ghc -c Foo.hs -W option Provides the standard warnings plus , + , , , , and @@ -991,6 +992,20 @@ foreign import "&f" f :: FunPtr t + : + + + + Causes a warning to be emitted when a datatype + T is exported + with all constructors, i.e. T(..), but is it + just a type synonym. + Also causes a warning to be emitted when a module is + re-exported, but that module exports nothing. + + + + :