OSDN Git Service

PR debug/43329
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / proc_ptr_comp_13.f90
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 <janus@gcc.gnu.org>
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) call abort()
24 if (o2%data /= 5) call abort()
25 if (.not. associated(o%ppc)) call abort()
26 if (associated(o2%ppc)) call abort()
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