view gcc/testsuite/gfortran.dg/unlimited_polymorphic_6.f90 @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

! { dg-do run }
!
! PR fortran/55763
!
! Contributed by Reinhold Bader
!
module mod_alloc_scalar_01
contains
  subroutine construct(this)
    class(*), allocatable, intent(out) :: this
    integer :: this_i
    this_i = 4
    allocate(this, source=this_i)
  end subroutine
end module

program alloc_scalar_01
  use mod_alloc_scalar_01
  implicit none
  class(*), allocatable :: mystuff

  call construct(mystuff)
  call construct(mystuff)

  select type(mystuff)
  type is (integer)
    if (mystuff == 4) then
!      write(*,*) 'OK'
    else 
      STOP 1
!     write(*,*) 'FAIL 1'
    end if
  class default
    STOP 2
!    write(*,*) 'FAIL 2'
  end select
end program