Fixed the nasty hack of checking for _sizes by checking the new NameSource field instead
To avoid problems with removing _sizes variables, we simply don't remove any nonce variables.
This commit is contained in:
parent
0e7a6c5b98
commit
ce03f2ca27
|
@ -282,13 +282,14 @@ checkUnusedVar = forAnyASTStructBottomUpAccum doSpec
|
||||||
doSpec (A.Spec _ (A.Specification mspec name _) scope)
|
doSpec (A.Spec _ (A.Specification mspec name _) scope)
|
||||||
= do -- We can't remove _sizes arrays because the backend uses them for bounds
|
= do -- We can't remove _sizes arrays because the backend uses them for bounds
|
||||||
-- checks that are not explicit in the AST. We'll have to move the
|
-- checks that are not explicit in the AST. We'll have to move the
|
||||||
-- bounds checking forward into the AST before we can remove them:
|
-- bounds checking forward into the AST before we can remove them.
|
||||||
when (not $ "_sizes" `isSuffixOf` A.nameName name) $
|
-- Making this more general, we don't actually remove any unused nonces.
|
||||||
|
nd <- lookupName name
|
||||||
|
when (A.ndNameSource nd == A.NameUser) $
|
||||||
do usedNames <- askAccum >>* delete name
|
do usedNames <- askAccum >>* delete name
|
||||||
-- ^ strip off one use of each name, since it's used in the spec
|
-- ^ strip off one use of each name, since it's used in the spec
|
||||||
when (not $ A.nameName name `elem` map A.nameName usedNames) $
|
when (not $ A.nameName name `elem` map A.nameName usedNames) $
|
||||||
do -- TODO have a way of not warning about compiler-generated names:
|
do warnPC mspec WarnUnusedVariable $ formatCode "Unused variable: %" name
|
||||||
warnPC mspec WarnUnusedVariable $ formatCode "Unused variable: %" name
|
modify (\st -> st { csNames = Map.delete (A.nameName name) (csNames st) })
|
||||||
modify (\st -> st { csNames = Map.delete (A.nameName name) (csNames st) })
|
substitute scope
|
||||||
substitute scope
|
|
||||||
doSpec _ = return ()
|
doSpec _ = return ()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user