PSyclone: [psyir] Check on whether dimensioning symbol is local does not work when symbol is in an ancestor scope.
For the following Fortran:
module my_mod
integer :: dim
contains
subroutine init()
dim = 10
end subroutine
subroutine work()
real, dimension(dim) :: my_array
end subroutine
end module
Then PSyclone complains:
If a local datasymbol is used as part of a dimension declaration then it should be a constant, but 'dim' is not.
The problem is in ArrayType._validate_shape where the Symbol being referred to in the shape specification is looked up. It is found to have a ‘local’ interface and not be a constant. Both of which are correct. However, no check is made on which SymbolTable the symbol is in.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 20 (7 by maintainers)
Commits related to this issue
- #1089 add test demonstrating problem. — committed to stfc/PSyclone by arporter 6 years ago
- #1089 rm check for non-constant, non-local dimensioning vars — committed to stfc/PSyclone by arporter 6 years ago
- #1089 Update changelog — committed to stfc/PSyclone by sergisiso 6 years ago
- Merge pull request #1101 from stfc/1089_dim_symbols Remove check on dimensioning symbols (towards #1089) — committed to stfc/PSyclone by sergisiso 6 years ago
Unless I’ve missed something, I think the problem is that we construct the shape list before we create the symbol to which it belongs (because we have to make the type first). We’d need to alter the
DataSymbolconstructor so thatdatatypewas optional. Rather than re-engineer the PSyIR classes, I think it would be more natural to do this check in e.g.psyir.backends.fortran.FortranWriter.gen_declssince that knows which symbol table it is dealing with.