PSyclone
PSyclone copied to clipboard
Complex expression in array declaration
This unit test shows the bug:
def test_psyclone_boundary_expr_wrong():
code = """subroutine foo(a,b,c,n)
integer :: n
real*8, dimension(1:) :: a
real*8, dimension(1:n) :: b
real*8, dimension(n:) :: c
real*8, dimension(:) :: d
end subroutine foo\n"""
reader = FortranReader()
psyir_tree = reader.psyir_from_source(code)
writer = FortranWriter()
output = writer(psyir_tree)
assert code == output
With this one gfortran -c test.f90 returns no error.
But with the one generated by psyclone, there is an error.
subroutine foo(a, b, c, n)
integer :: n
- real*8, dimension() :: a
+ real*8, dimension(1:) :: a
? ++
- real*8, dimension(n) :: b
+ real*8, dimension(1:n) :: b
? ++
real*8, dimension(n:) :: c
real*8, dimension(:) :: d
end subroutine foo
Here the error
>> gfortran test.f90 -c
test.f90:3:21:
3 | real*8, dimension() :: a
| 1
Error: Expected expression in array specification at (1)