opt_Verbose,
opt_WarnNameShadowing,
- opt_WarnUnusedNames,
- opt_WarnUnusedTopLevel,
+ opt_WarnUnusedMatches,
+ opt_WarnUnusedBinds,
opt_WarnUnusedImports,
opt_WarnIncompletePatterns,
opt_WarnOverlappingPatterns,
opt_WarnIncompletePatterns = lookUp SLIT("-fwarn-incomplete-patterns")
opt_WarnOverlappingPatterns = lookUp SLIT("-fwarn-overlapping-patterns")
opt_WarnSimplePatterns = lookUp SLIT("-fwarn-simple-patterns")
-opt_WarnUnusedNames = lookUp SLIT("-fwarn-unused-names")
-opt_WarnUnusedTopLevel = lookUp SLIT("-fwarn-unused-toplevel")
+opt_WarnUnusedMatches = lookUp SLIT("-fwarn-unused-matches")
+opt_WarnUnusedBinds = lookUp SLIT("-fwarn-unused-binds")
opt_WarnUnusedImports = lookUp SLIT("-fwarn-unused-imports")
opt_WarnMissingMethods = lookUp SLIT("-fwarn-missing-methods")
opt_WarnDuplicateExports = lookUp SLIT("-fwarn-duplicate-exports")
import CmdLineOpts ( opt_HiMap, opt_WarnNameShadowing, opt_D_show_rn_trace,
opt_D_dump_rn, opt_D_show_rn_stats,
- opt_WarnUnusedNames
+ opt_WarnUnusedBinds, opt_WarnUnusedImports
)
import RnMonad
import RnNames ( getGlobalNames )
)
import TysWiredIn ( unitTyCon, intTyCon, doubleTyCon )
import TyCon ( TyCon )
-import PrelMods ( mAIN, gHC_MAIN )
+import PrelMods ( mAIN, pREL_MAIN )
import PrelInfo ( ioTyCon_NAME )
import ErrUtils ( pprBagOfErrors, pprBagOfWarnings,
doIfSet, dumpIfSet, ghcExit
-- Add occurrences for IO or PrimIO
implicit_main | mod_name == mAIN
- || mod_name == gHC_MAIN = [ioTyCon_NAME]
+ || mod_name == pREL_MAIN = [ioTyCon_NAME]
| otherwise = []
\end{code}
\begin{code}
reportUnusedNames explicit_avail_names
- | not opt_WarnUnusedNames
- = returnRn ()
-
- | otherwise
= getSlurpedNames `thenRn` \ slurped_names ->
let
unused = explicit_avail_names `minusNameSet` slurped_names
imports_by_module = equivClasses cmp imported_unused
name1 `cmp` name2 = nameModule name1 `compare` nameModule name2
- pp_imp = sep [text "For information: the following unqualified imports are unused:",
+ pp_imp = sep [text "Warning: the following unqualified imports are unused:",
nest 4 (vcat (map pp_group imports_by_module))]
pp_group (n:ns) = sep [hcat [text "Module ", pprModule (nameModule n), char ':'],
nest 4 (sep (map (pprOccName . nameOccName) (n:ns)))]
- pp_local = sep [text "For information: the following local top-level definitions are unused:",
+ pp_local = sep [text "Warning: the following local top-level definitions are unused:",
nest 4 (sep (map (pprOccName . nameOccName) local_unused))]
in
- (if null imported_unused
+ (if not opt_WarnUnusedImports || null imported_unused
then returnRn ()
else addWarnRn pp_imp) `thenRn_`
- (if null local_unused
+ (if not opt_WarnUnusedBinds || null local_unused
then returnRn ()
else addWarnRn pp_local)
import RnMonad
import RnExpr ( rnMatch, rnGRHSsAndBinds, rnPat, checkPrecMatch )
import RnEnv ( bindLocatedLocalsRn, lookupBndrRn, lookupOccRn,
- newLocalNames, isUnboundName, warnUnusedNames
+ newLocalNames, isUnboundName, warnUnusedBinds
)
import CmdLineOpts ( opt_SigsRequired )
import Digraph ( stronglyConnComp, SCC(..) )
let
unused_binders = binder_set `minusNameSet` (fv_set `unionNameSets` exported_binders)
in
- warnUnusedNames unused_binders `thenRn_`
+ warnUnusedBinds unused_binders `thenRn_`
returnRn new_binds
where
binder_rdr_names = map fst (bagToList (collectMonoBinders mbinds))
net_fvs = all_fvs `minusNameSet` binder_set
unused_binders = binder_set `minusNameSet` all_fvs
in
- warnUnusedNames unused_binders `thenRn_`
+ warnUnusedBinds unused_binders `thenRn_`
returnRn (result, net_fvs)
where
mbinders_w_srclocs = bagToList (collectMonoBinders mbinds)
#include "HsVersions.h"
-import CmdLineOpts ( opt_WarnNameShadowing, opt_WarnUnusedNames )
+import CmdLineOpts ( opt_WarnNameShadowing, opt_WarnUnusedMatches,
+ opt_WarnUnusedBinds, opt_WarnUnusedImports )
import HsSyn
import RdrHsSyn ( RdrName(..), RdrNameIE,
rdrNameOcc, ieOcc, isQual, qual
\begin{code}
+warnUnusedBinds, warnUnusedMatches, warnUnusedImports :: NameSet -> RnM s d ()
+
+warnUnusedBinds names
+ | opt_WarnUnusedBinds = warnUnusedNames names
+ | otherwise = returnRn ()
+
+warnUnusedMatches names
+ | opt_WarnUnusedMatches = warnUnusedNames names
+ | otherwise = returnRn ()
+
+warnUnusedImports names
+ | opt_WarnUnusedImports = warnUnusedNames names
+ | otherwise = returnRn ()
+
warnUnusedNames :: NameSet -> RnM s d ()
warnUnusedNames names
- | not opt_WarnUnusedNames = returnRn ()
- | otherwise = mapRn warn (nameSetToList names) `thenRn_`
- returnRn ()
+ = mapRn warn (nameSetToList names) `thenRn_`
+ returnRn ()
where
warn name = pushSrcLocRn (getSrcLoc name) $
addWarnRn (unusedNameWarn name)
unused_binders = binder_set `minusNameSet` fvs
net_fvs = fvs `minusNameSet` binder_set
in
- warnUnusedNames unused_binders `thenRn_`
+ warnUnusedMatches unused_binders `thenRn_`
+
returnRn (match', net_fvs)
where
get_binders (GRHSMatch _) = []
import Type ( namesOfType )
import TyVar ( GenTyVar )
import SrcLoc ( mkSrcLoc, SrcLoc )
-import PrelMods ( gHC__ )
+import PrelMods ( pREL_GHC )
import PrelInfo ( cCallishTyKeys )
import Bag
import Maybes ( MaybeErr(..), expectJust, maybeToBool )
mod = nameModule main_name
doc_str = sep [ptext SLIT("need home module for wired in thing"), ppr name]
in
- (if not main_is_tc || mod == gHC__ then
+ (if not main_is_tc || mod == pREL_GHC then
returnRn ()
else
loadInterface doc_str mod (ifaceFlavour main_name) `thenRn_`
<tag>@-W@:</tag>
<nidx>-W option</nidx>
-Provides the standard warnings plus @-fwarn-incomplete-patterns@
-and @-fwarn-unused-names@.
+Provides the standard warnings plus @-fwarn-incomplete-patterns@,
+@-fwarn-unused-imports@ and @-fwarn-unused-binds@.
<tag>@-Wall@:</tag>
<nidx>-Wall option</nidx>
declaration is missing one or more methods, and the corresponding
class declaration has no default declaration for them.
-<tag>@-fwarn-unused-names@:</tag>
-<nidx>-fwarn-unused-names option</nidx>
-<nidx>unused names, warning</nidx>
-<nidx>names, unused</nidx>
+<tag>@-fwarn-unused-imports@:</tag>
+<nidx>-fwarn-unused-imports option</nidx>
+<nidx>unused imports, warning</nidx>
+<nidx>imports, unused</nidx>
-Have the renamer report which locally defined names are not used/exported.
+Report any objects that are explicitly imported but never used.
+
+<tag>@-fwarn-unused-binds@:</tag>
+<nidx>-fwarn-unused-binds option</nidx>
+<nidx>unused binds, warning</nidx>
+<nidx>binds, unused</nidx>
+
+Report any function definitions (and local bindings) which are unused.
+For top-level functions, the warning is only given if the binding is
+not exported.
+
+<tag>@-fwarn-unused-matches@:</tag>
+<nidx>-fwarn-unused-matches option</nidx>
+<nidx>unused matches, warning</nidx>
+<nidx>matches, unused</nidx>
+
+Report all unused variables which arise from pattern matches,
+including patterns consisting of a single variable. For instance @f x
+y = []@ would report @x@ and @y@ as unused. To eliminate the warning,
+all unused variables can be replaced with wildcards.
<tag>@-fwarn-duplicate-exports@:</tag>
<nidx>-fwarn-duplicate-exports option</nidx>
#
$InstLibExecDirGhc = "${libexecdir}";
$InstDataDirGhc = "${datadir}";
-$InstSysLibDir = ( $INSTALLING ) ? "${InstLibDirGhc}/hslibs" : "$TopPwd/hslibs";
$Status = 0; # just used for exit() status
$Verbose = '';
'-fwarn-duplicate-exports');
@MinusWOpts = (@StandardWarnings,
'-fwarn-incomplete-patterns',
- '-fwarn-unused-names');
+ '-fwarn-unused-binds',
+ '-fwarn-unused-imports');
@MinusWallOpts = (@MinusWOpts,
+ '-fwarn-unused-matches',
'-fwarn-name-shadowing');
\end{code}
@Import_dir = ('.'); #-i things
@Include_dir = ('.'); #-I things; other default(s) stuck on AFTER option processing
-# where to look for interface files (system hi's, i.e., prelude and hslibs)
+# where to look for interface files (system hi's, i.e., prelude and syslibs)
@SysImport_dir = ( $INSTALLING )
- ? ( "$InstLibDirGhc/imports" )
- : ( "$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR/required"
- , "$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR/ghc"
- , "$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR/glaExts"
- , "$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR/concurrent" );
+ ? ( "$InstLibDirGhc/imports/std" )
+ : ( "$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR/std" );
# We need to look in ghc/ and glaExts/ when searching for implicitly needed .hi files, but
# we should really *not* look there for explicitly imported modules.
? $InstLibDirGhc
: ( "$TopPwd/$CURRENT_DIR/$GHC_RUNTIME_DIR"
, "$TopPwd/$CURRENT_DIR/$GHC_RUNTIME_DIR/gmp"
- , "$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR"
- , "$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR/cbits"
+ , "$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR/std"
+ , "$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR/std/cbits"
)
);
@SysLibrary = (); # will be built up as we go along
local($syslib) = @_;
unshift(@SysImport_dir,
- ${INSTALLING} ? "$InstSysLibDir/$syslib/imports"
- : "$TopPwd/hslibs/$syslib/src");
+ ${INSTALLING} ? "$InstLibDir/imports/$syslib"
+ : "$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR/$syslib");
push(@SysLibrary_dir,
- ${INSTALLING} ? ("$InstSysLibDir")
- : ("$TopPwd/hslibs/$syslib",
- "$TopPwd/hslibs/$syslib/cbits"));
+ ${INSTALLING} ? ("$InstLibDir")
+ : ("$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR/$syslib",
+ "$TopPwd/$CURRENT_DIR/$GHC_LIB_DIR/$syslib/cbits"));
push(@SysLibrary, "-lHS$syslib");
push(@SysLibrary, "-lHS${syslib}_cbits")
- unless $syslib eq 'contrib'; #HACK! it has no cbits
+ unless $syslib eq 'contrib' || $syslib eq 'exts';
+ #HACK! they have no cbits
}
\end{code}
#--------- ticky/concurrent/parallel -----------------------------------
# we sort out the details a bit later on
- /^-concurrent$/ && do { $CONCURing = 'c'; next arg; }; # concurrent Haskell
+ /^-concurrent$/ && do { $CONCURing = 'c'; &add_syslib('conc'); next arg; };
+ # concurrent Haskell; implies -syslib conc
/^-gransim$/ && do { $GRANing = 'g'; next arg; }; # GranSim
/^-ticky$/ && do { $TICKYing = 't'; next arg; }; # ticky-ticky
/^-parallel$/ && do { $PARing = 'p'; next arg; }; # parallel Haskell
push(@HsP_flags, '-N');
# push(@HsC_flags, '-fshow-import-specs');
+
+ # -fglasgow-exts implies -syslib exts
+ &add_syslib('exts');
next arg; };