summaryrefslogtreecommitdiff
path: root/compiler/rename
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2009-07-19 20:01:24 +0000
committerIan Lynagh <igloo@earth.li>2009-07-19 20:01:24 +0000
commit76c6727d14fe738f4460882739dd462686b008b9 (patch)
treec63cf489676c4b631dd5bf33efd180130ad56411 /compiler/rename
parent5c8d5090cfbb3b239c6ce17a27bcf65637296dd9 (diff)
downloadhaskell-76c6727d14fe738f4460882739dd462686b008b9.tar.gz
Add a -fwarn-dodgy-exports flag; fixes #1911
This is used to control warnings that were previously unconditional.
Diffstat (limited to 'compiler/rename')
-rw-r--r--compiler/rename/RnNames.lhs17
1 files changed, 10 insertions, 7 deletions
diff --git a/compiler/rename/RnNames.lhs b/compiler/rename/RnNames.lhs
index 1052db6848..63f29d9af0 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)