view gcc/testsuite/gfortran.dg/select_type_42.f90 @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 84e7813d76e9
children
line wrap: on
line source

! { 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