Fix bug where list elements of global declarations were removed.

CleanNode was too greedy, because children of global declarations (particularly lists) are not marked executable. Make a special case for them and don't recurse, since what matters is whether the declaration itself is executed. Its contents can't be cleaned up.
This commit is contained in:
Sei Lisa 2017-10-16 00:55:56 +02:00
parent f77590df67
commit cc96850f66

View file

@ -362,7 +362,8 @@ class deadcode(object):
"""Recursively checks if the children are used, deleting those that are
not.
"""
if 'ch' not in curnode:
if 'ch' not in curnode or (curnode['nt'] == 'DECL'
and curnode['scope'] == 0):
return
# NOTE: Should not depend on 'Loc', since the nodes that are the
# destination of 'Loc' are renumbered as we delete stuff from globals.