PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

Complex expression in array declaration

Open hbrunie opened this issue 1 year ago • 0 comments

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)

hbrunie avatar Sep 25 '24 08:09 hbrunie