Commit 75ebc06a authored by simonpj@microsoft.com's avatar simonpj@microsoft.com
Browse files

Clamp -O flag to beween 0 and 2

Fixes Trac #1272
parent 11d36d9f
...@@ -561,13 +561,14 @@ data Option ...@@ -561,13 +561,14 @@ data Option
updOptLevel :: Int -> DynFlags -> DynFlags updOptLevel :: Int -> DynFlags -> DynFlags
-- Set dynflags appropriate to the optimisation level -- Set dynflags appropriate to the optimisation level
updOptLevel n dfs updOptLevel n dfs
= dfs2{ optLevel = n } = dfs2{ optLevel = final_n }
where where
final_n = max 0 (min 2 n) -- Clamp to 0 <= n <= 2
dfs1 = foldr (flip dopt_unset) dfs remove_dopts dfs1 = foldr (flip dopt_unset) dfs remove_dopts
dfs2 = foldr (flip dopt_set) dfs1 extra_dopts dfs2 = foldr (flip dopt_set) dfs1 extra_dopts
extra_dopts = [ f | (ns,f) <- optLevelFlags, n `elem` ns ] extra_dopts = [ f | (ns,f) <- optLevelFlags, final_n `elem` ns ]
remove_dopts = [ f | (ns,f) <- optLevelFlags, n `notElem` ns ] remove_dopts = [ f | (ns,f) <- optLevelFlags, final_n `notElem` ns ]
optLevelFlags :: [([Int], DynFlag)] optLevelFlags :: [([Int], DynFlag)]
optLevelFlags optLevelFlags
......
Supports Markdown
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