| 1 |
! { dg-do compile } |
| 2 |
! |
| 3 |
! PR fortran/57364 |
| 4 |
! |
| 5 |
! Contributed by Damian Rouson |
| 6 |
! |
| 7 |
module ref_counter_implementation |
| 8 |
type ref_counter |
| 9 |
contains |
| 10 |
procedure :: assign |
| 11 |
generic :: assignment(=) => assign |
| 12 |
end type |
| 13 |
contains |
| 14 |
subroutine assign (lhs, rhs) |
| 15 |
class (ref_counter), intent(inout) :: lhs |
| 16 |
class (ref_counter), intent(in) :: rhs |
| 17 |
end subroutine |
| 18 |
end module |
| 19 |
module foo_parent_implementation |
| 20 |
use ref_counter_implementation ,only: ref_counter |
| 21 |
type :: foo_parent |
| 22 |
type(ref_counter) :: counter |
| 23 |
end type |
| 24 |
contains |
| 25 |
type(foo_parent) function new_foo_parent() |
| 26 |
end function |
| 27 |
end module |
| 28 |
module foo_implementation |
| 29 |
use foo_parent_implementation ,only: foo_parent,new_foo_parent |
| 30 |
type, extends(foo_parent) :: foo |
| 31 |
end type |
| 32 |
contains |
| 33 |
type(foo) function new_foo() |
| 34 |
new_foo%foo_parent = new_foo_parent() |
| 35 |
end function |
| 36 |
end module |