Skip to content

Commit 4f74623

Browse files
committed
Calculate LBOUND / UBOUND dependency
For local variables and parameters, the lbound / ubound dependency is "chained", so it correctly guesses if an array variable that is used in a function call needs LBOUND.
1 parent 3aba443 commit 4f74623

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

api/optimize.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ def _visit(self, node):
6969
return None
7070

7171
__DEBUG__("Optimizer: Visiting node {}".format(str(node.obj)), 1)
72-
73-
# print node.obj.token, node.obj.__repr__()
7472
methname = 'visit_' + node.obj.token
7573
meth = getattr(self, methname, None)
7674
if meth is None:
@@ -267,13 +265,15 @@ def _check_if_any_arg_is_an_array_and_needs_lbound_or_ubound(self, params: symbo
267265
if arg.value.lbound_used and arg.value.ubound_used:
268266
continue
269267

270-
self._update_bound_status(arg.value, param, params.parent)
268+
self._update_bound_status(arg.value)
271269

272-
def _update_bound_status(self, arg: symbols.VARARRAY, param: symbols.PARAMDECL, func: symbols.FUNCTION):
270+
def _update_bound_status(self, arg: symbols.VARARRAY):
273271
old_lbound_used = arg.lbound_used
274272
old_ubound_used = arg.ubound_used
275-
arg.lbound_used = arg.lbound_used or param.lbound_used
276-
arg.ubound_used = arg.ubound_used or param.ubound_used
273+
274+
for p in arg.requires:
275+
arg.lbound_used = arg.lbound_used or p.lbound_used
276+
arg.ubound_used = arg.ubound_used or p.ubound_used
277277

278278
if old_lbound_used != arg.lbound_used or old_ubound_used != arg.ubound_used:
279279
if arg.scope == SCOPE.global_:

0 commit comments

Comments
 (0)