Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
94434054
Commit
94434054
authored
Apr 25, 2011
by
dterei
Browse files
SafeHaskell: Force all imports to be safe in Safe mode
parent
6de1b0f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
compiler/iface/MkIface.lhs
View file @
94434054
...
@@ -907,9 +907,11 @@ mk_usage_info pit hsc_env this_mod direct_imports used_names
...
@@ -907,9 +907,11 @@ mk_usage_info pit hsc_env this_mod direct_imports used_names
(is_direct_import, imp_safe)
(is_direct_import, imp_safe)
= case lookupModuleEnv direct_imports mod of
= case lookupModuleEnv direct_imports mod of
Just ((_,_,_,safe):xs) -> (True, safe)
Just ((_,_,_,safe):_xs) -> (True, safe)
Just _ -> pprPanic "mkUsage: empty direct import" empty
Just _ -> pprPanic "mkUsage: empty direct import" empty
Nothing -> (False, False)
Nothing -> (False, safeImportsRequired dflags)
-- Nothing case is for implicit imports like 'System.IO' when 'putStrLn'
-- is used in the source code. We require them to be safe in SafeHaskell
used_occs = lookupModuleEnv ent_map mod `orElse` []
used_occs = lookupModuleEnv ent_map mod `orElse` []
...
...
compiler/main/DynFlags.hs
View file @
94434054
...
@@ -31,8 +31,10 @@ module DynFlags (
...
@@ -31,8 +31,10 @@ module DynFlags (
fFlags
,
fLangFlags
,
xFlags
,
fFlags
,
fLangFlags
,
xFlags
,
DPHBackend
(
..
),
dphPackageMaybe
,
DPHBackend
(
..
),
dphPackageMaybe
,
wayNames
,
wayNames
,
-- ** SafeHaskell
SafeHaskellMode
(
..
),
SafeHaskellMode
(
..
),
safeHaskellOn
,
safeHaskellOn
,
safeImportsRequired
,
Settings
(
..
),
Settings
(
..
),
ghcUsagePath
,
ghciUsagePath
,
topDir
,
tmpDir
,
rawSettings
,
ghcUsagePath
,
ghciUsagePath
,
topDir
,
tmpDir
,
rawSettings
,
...
@@ -985,6 +987,11 @@ setSafeHaskell s = upd f
...
@@ -985,6 +987,11 @@ setSafeHaskell s = upd f
safeHaskell
=
combineSafeFlags
sf
s
safeHaskell
=
combineSafeFlags
sf
s
}
}
-- | Are all imports required to be safe for this SafeHaskell mode?
safeImportsRequired
::
DynFlags
->
Bool
safeImportsRequired
dflags
=
m
==
Sf_SafeLanguage
||
m
==
Sf_Safe
where
m
=
safeHaskell
dflags
-- | Combine two SafeHaskell modes correctly. Used for dealing with multiple flags.
-- | Combine two SafeHaskell modes correctly. Used for dealing with multiple flags.
-- This makes SafeHaskell very much a monoid but for now I prefer this as I don't
-- This makes SafeHaskell very much a monoid but for now I prefer this as I don't
-- want to export this functionality from the module but do want to export the
-- want to export this functionality from the module but do want to export the
...
...
compiler/rename/RnNames.lhs
View file @
94434054
...
@@ -219,8 +219,10 @@ rnImportDecl this_mod implicit_prelude
...
@@ -219,8 +219,10 @@ rnImportDecl this_mod implicit_prelude
Just (is_hiding, ls) -> not is_hiding && null ls
Just (is_hiding, ls) -> not is_hiding && null ls
_ -> False
_ -> False
mod_safe' = mod_safe || safeImportsRequired dflags
imports = ImportAvails {
imports = ImportAvails {
imp_mods = unitModuleEnv imp_mod [(qual_mod_name, import_all, loc, mod_safe)],
imp_mods = unitModuleEnv imp_mod [(qual_mod_name, import_all, loc, mod_safe
'
)],
imp_orphs = orphans,
imp_orphs = orphans,
imp_finsts = finsts,
imp_finsts = finsts,
imp_dep_mods = mkModDeps dependent_mods,
imp_dep_mods = mkModDeps dependent_mods,
...
@@ -234,7 +236,7 @@ rnImportDecl this_mod implicit_prelude
...
@@ -234,7 +236,7 @@ rnImportDecl this_mod implicit_prelude
_ -> return ()
_ -> return ()
)
)
let new_imp_decl = L loc (ImportDecl loc_imp_mod_name mb_pkg want_boot mod_safe
let new_imp_decl = L loc (ImportDecl loc_imp_mod_name mb_pkg want_boot mod_safe
'
qual_only as_mod new_imp_details)
qual_only as_mod new_imp_details)
return (new_imp_decl, gbl_env, imports, mi_hpc iface)
return (new_imp_decl, gbl_env, imports, mi_hpc iface)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment