Debian Codegraph @

gcc/testsuite/gfortran.dg/forall_20.f90

raw
1 !{ dg-do run }
2 !
3 ! Check pointer aliasing is done w/o temp.
4 ! Contributed by Arseny Solokha <[email protected]>
5
6 program pr107143
7 type ta
8 integer, POINTER :: ip(:)
9 end type ta
10
11 type tb
12 integer, POINTER :: ip(:,:)
13 end type tb
14
15 integer, parameter :: cnt = 3
16 type(ta) :: a(cnt)
17 type(tb) :: b(cnt)
18 integer, target :: arr(8) = [1,2,3,4,5,6,7,8]
19
20 do i = 1, cnt
21 allocate(a(i)%ip(8), SOURCE=arr * i)
22 end do
23 call s5(b, a, 2, 4)
24
25 do i = 1, cnt
26 if (any(b(i)%ip /= reshape(arr * i, [2, 4]))) stop i
27 end do
28
29 contains
30
31 subroutine s5(y,z,n1,n2)
32
33 type(tb) :: y(:)
34 type(ta), TARGET :: z(:)
35
36 forall (i=1:cnt)
37 y(i)%ip(1:n1,1:n2) => z(i)%ip
38 end forall
39 end subroutine s5
40 end program