summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/allocate_class_4.f90
blob: 23c9d53d171feb61f16e289bac469b24acdee87e (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
27
28
29
30
31
32
33
34
35
36
! { dg-do compile }
!
! Part of PR 51946, but breaks easily, therefore introduce its own test
! Authors: Damian Rouson  <damian@sourceryinstitute.org>,
!          Dominique Pelletier  <dominique.pelletier@polymtl.ca>
! Contributed by: Andre Vehreschild  <vehre@gcc.gnu.org>

module integrable_model_module

   implicit none

   type, abstract, public :: integrable_model
      contains
         procedure(default_constructor), deferred :: empty_instance
   end type

   abstract interface
      function default_constructor(this) result(blank_slate)
         import :: integrable_model
         class(integrable_model), intent(in)  :: this
         class(integrable_model), allocatable :: blank_slate
      end function
   end interface

   contains

      subroutine integrate(this)
         class(integrable_model), intent(inout) :: this
         class(integrable_model), allocatable   :: residual
         allocate(residual, source=this%empty_instance())
      end subroutine

end module integrable_model_module

! { dg-final { cleanup-modules "integrable_model_module" } }