summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/associate_20.f03
blob: 884931155f72cd0ce476ef736e84a5b31fd32d4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
! { dg-do run }
!
! Contributed by mrestelli@gmail.com
! Adapated by Andre Vehreschild  <vehre@gcc.gnu.org>
! Test that fix for PR69296 is working.

program p
  implicit none

  type foo
    integer :: i
  end type

  integer :: j, i(3,2)
  class(foo), allocatable :: a(:,:)

  allocate (a(2,6))

  a(1,:)%i = (/ (     j , j=1,6) /)
  a(2,:)%i = (/ ( -10*j , j=1,6) /)

  i(:,1) = (/ 1 , 3 , 5 /)
  i(:,2) = (/ 4 , 5 , 6 /)

  associate( ai => a(:,i(:,1))%i )
    if (any(shape(ai) /= [2, 3])) STOP 1
    if (any(reshape(ai, [6]) /= [1 , -10, 3, -30, 5, -50])) STOP 2
  end associate

  deallocate(a)
end program p