view gcc/testsuite/gfortran.dg/type_to_class_4.f03 @ 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 }
!
! Test the fix for PR56691 comment #7 (and comment #0).
!
! Reduced from the original of Marco Restelli  <mrestelli@gmail.com>
! by Janus Weil  <janus@gcc.gnu.org>
!
module m2
  implicit none
  type :: t_stv
    real :: f1
  end type
contains
  subroutine lcb(y)
    class(t_stv), intent(in) :: y(:)
    integer :: k
    do k=1,size(y)
      if (int(y(k)%f1) .ne. k) STOP 1
    enddo
  end subroutine
end module

program test
 use m2
 implicit none

 type(t_stv), allocatable :: work(:)

  allocate(work(4))
  work(:)%f1 = (/ 1.,2.,3.,4./)

  call lcb(work)
  call lcb(work(:4)) ! Indexing used to be offset by 1.

end program