From cc96850f66cd0cf0c9ae2b370534f4d9d82b9020 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Mon, 16 Oct 2017 00:55:56 +0200 Subject: [PATCH] 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. --- lslopt/lsldeadcode.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lslopt/lsldeadcode.py b/lslopt/lsldeadcode.py index fb199eb..c5556eb 100644 --- a/lslopt/lsldeadcode.py +++ b/lslopt/lsldeadcode.py @@ -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.