view gcc/testsuite/gfortran.dg/class_dummy_5.f90 @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

! { dg-do compile }
!
! PR 54756: [OOP] [F08] Should reject CLASS, intent(out) in PURE procedures
!
! Contributed by Tobias Burnus <burnus@gcc.gnu.org>

module m
  type t
  contains
    final :: fnl   ! impure finalizer
  end type t
contains
  impure subroutine fnl(x)
    type(t) :: x
    print *,"finalized!"
  end subroutine
end

program test
  use m
  type(t) :: x
  call foo(x)
contains
  pure subroutine foo(x)  ! { dg-error "may not be polymorphic" }
    ! pure subroutine would call impure finalizer
    class(t), intent(out) :: x
  end subroutine
end