Plugins: Add label-text.h to CPPLIB_H so it will be installed [PR115288]
[official-gcc.git] / gcc / testsuite / gfortran.dg / pointer_array_component_3.f90
blob8ef205bc14fe813f066d35616b57c8a4889f18b8
1 ! { dg-do run }
3 ! Test the fix for PR88685, in which the component array references in 'doit'
4 ! were being ascribed to the class pointer 'Cls' itself so that the stride
5 ! measure between elements was wrong.
7 ! Contributed by Antony Lewis <antony@cosmologist.info>
9 program tester
10 implicit none
11 Type TArr
12 integer, allocatable :: CL(:)
13 end Type TArr
15 type(TArr), allocatable, target :: arr(:,:)
16 class(TArr), pointer:: Cls(:,:)
17 integer i
19 allocate(arr(1,1))
20 allocate(arr(1,1)%CL(3))
21 arr(1,1)%CL=-1
22 cls => arr
23 call doit(cls)
24 if (any (arr(1,1)%cl .ne. [3,2,1])) stop 3
25 contains
26 subroutine doit(cls)
27 class(TArr), pointer :: Cls(:,:)
29 cls(1,1)%CL(1) = 3
30 cls(1,1)%CL(2:3) = [2,1]
32 if (any (Cls(1,1)%CL .ne. [3,2,1])) stop 1
33 if (Cls(1,1)%CL(2) .ne. 2) stop 2
35 end subroutine doit
36 end program tester