Skip to content

Commit

Permalink
STMT FUNC: allow other variables to be declared alongside statement f…
Browse files Browse the repository at this point in the history
…unction return var
  • Loading branch information
awnawab committed Nov 15, 2023
1 parent 5a177b5 commit d82a1d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions loki/frontend/fparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,11 +1812,12 @@ def visit_Subroutine_Subprogram(self, o, **kwargs):
rescope_symbols=True, source=source, incomplete=False
)

# Once statement functions are in place, we need to update the original declaration symbol
# Once statement functions are in place, we need to update the original declaration so that it
# contains ProcedureSymbols rather than Scalars
for decl in FindNodes(ir.VariableDeclaration).visit(spec):
if any(routine.symbol_attrs[s.name].is_stmt_func for s in decl.symbols):
assert all(routine.symbol_attrs[s.name].is_stmt_func for s in decl.symbols)
decl._update(symbols=tuple(s.clone() for s in decl.symbols))
decl._update(symbols=tuple(s.clone() if routine.symbol_attrs[s.name].is_stmt_func else s
for s in decl.symbols))

# Big, but necessary hack:
# For deferred array dimensions on allocatables, we infer the conceptual
Expand Down
3 changes: 1 addition & 2 deletions tests/test_subroutine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,8 +1493,7 @@ def test_subroutine_stmt_func(here, frontend):
integer, intent(in) :: a
integer, intent(out) :: b
integer :: array(a)
integer :: i, j
integer :: plus, minus
integer :: i, j, plus, minus
plus(i, j) = i + j
minus(i, j) = i - j
integer :: mult
Expand Down

0 comments on commit d82a1d7

Please sign in to comment.