aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/select_type_42.f90
blob: ff73e6c78583acf35df5ffdc304375014623e8fe (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
! { dg-do run }
!
! Tests the fix for PR82275.
! Associating a name with a reduced-dimension section of a
! multidimensional array precluded subsequent use of the name
! with the appropriately reduced dimensionality and instead
! required use of the (invalid) full set of original dimensions.
!
! Contributed by Damian Rouson  <damian@sourceryinstitute.org>
!
  type component
   integer :: i
  end type
  type container
    class(component), allocatable :: component_array(:,:)
  end type
  type(container) bag
  type(component) section_copy
  allocate(bag%component_array, source = reshape ([component(10), component (100)], [1,2]))
  select type(associate_name=>bag%component_array(1,:))
    type is (component)
      section_copy = associate_name(2)  ! gfortran rejected valid
!      section_copy = associate_name(1,1)! gfortran accepted invalid
  end select
  if (section_copy%i .ne. 100) stop 1
end