| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! PR 40882: [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type. |
| 4 |
! At the same time, check that a formal argument does not cause infinite recursion (PR 40870). |
| 5 |
! |
| 6 |
! Contributed by Janus Weil <[email protected]> |
| 7 |
|
| 8 |
implicit none |
| 9 |
|
| 10 |
type :: t |
| 11 |
integer :: data |
| 12 |
procedure(foo), pointer, nopass :: ppc |
| 13 |
procedure(type(t)), pointer, nopass :: ppc2 |
| 14 |
end type |
| 15 |
|
| 16 |
type(t) :: o,o2 |
| 17 |
|
| 18 |
o%data = 1 |
| 19 |
o%ppc => foo |
| 20 |
|
| 21 |
o2 = o%ppc(o) |
| 22 |
|
| 23 |
if (o%data /= 1) STOP 1 |
| 24 |
if (o2%data /= 5) STOP 2 |
| 25 |
if (.not. associated(o%ppc)) STOP 3 |
| 26 |
if (associated(o2%ppc)) STOP 4 |
| 27 |
|
| 28 |
contains |
| 29 |
|
| 30 |
function foo(arg) |
| 31 |
type(t) :: foo, arg |
| 32 |
foo%data = arg%data * 5 |
| 33 |
foo%ppc => NULL() |
| 34 |
end function |
| 35 |
|
| 36 |
end |
| 37 |
|