Skip to content

Commit 5551731

Browse files
committed
[gfortran] Fixed cray_pointers_2.f90 aliasing issues.
The test started failing after llvm/llvm-project#140803 The issue is that the Cray pointee and the underlying storage are both accessed in subroutines violating Fortran aliasing rules for the dummy arguments. GCC tried to "solve" that by using `-fno-inline` option, but it should be better to make the aliasing explicit with proper `TARGET` attribute placement.
1 parent 460eedc commit 5551731

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Fortran/gfortran/regression/cray_pointers_2.f90

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3474,6 +3474,19 @@ end subroutine ptr13
34743474

34753475
! Test the passing of pointers and pointees as parameters
34763476
subroutine parmtest
3477+
interface
3478+
subroutine parmptr(ipointer,intarr,n,m)
3479+
integer :: n,m
3480+
integer, target :: intarr(m,n)
3481+
pointer (ipointer,newpte)
3482+
integer, target :: newpte(m,n)
3483+
end subroutine parmptr
3484+
subroutine parmpte(pointee,intarr,n,m)
3485+
integer :: n,m
3486+
integer, target :: pointee (m,n)
3487+
integer, target :: intarr (m,n)
3488+
end subroutine parmpte
3489+
end interface
34773490
integer, parameter :: n = 12
34783491
integer, parameter :: m = 13
34793492
integer iarray(m,n)
@@ -3491,9 +3504,9 @@ subroutine parmptr(ipointer,intarr,n,m)
34913504
common /errors/errors(400)
34923505
logical :: errors, intne
34933506
integer :: n,m,i,j
3494-
integer intarr(m,n)
3507+
integer, target :: intarr(m,n)
34953508
pointer (ipointer,newpte)
3496-
integer newpte(m,n)
3509+
integer, target :: newpte(m,n)
34973510
! write(*,*) "loc(newpte)",loc(newpte)
34983511
! write(*,*) "loc(intarr)",loc(intarr)
34993512
! write(*,*) "loc(newpte(1,1))",loc(newpte(1,1))
@@ -3522,8 +3535,8 @@ subroutine parmpte(pointee,intarr,n,m)
35223535
common /errors/errors(400)
35233536
logical :: errors, intne
35243537
integer :: n,m,i,j
3525-
integer pointee (m,n)
3526-
integer intarr (m,n)
3538+
integer, target :: pointee (m,n)
3539+
integer, target :: intarr (m,n)
35273540
! write(*,*) "loc(pointee)",loc(pointee)
35283541
! write(*,*) "loc(intarr)",loc(intarr)
35293542
! write(*,*) "loc(pointee(1,1))",loc(pointee(1,1))

0 commit comments

Comments
 (0)