1! { dg-do run }
2! Tests the fix for PR68196
3!
4! Contributed by Damian Rouson  <damian@sourceryinstitute.org>
5!
6  type AA
7    integer :: i
8    procedure(foo), pointer :: funct
9  end type
10  class(AA), allocatable :: my_AA
11  type(AA) :: res
12
13  allocate (my_AA, source = AA (1, foo))
14
15  res = my_AA%funct ()
16
17  if (res%i .ne. 3) call abort
18  if (.not.associated (res%funct)) call abort
19  if (my_AA%i .ne. 4) call abort
20  if (associated (my_AA%funct)) call abort
21
22contains
23  function foo(A)
24    class(AA), allocatable :: A
25    type(AA) foo
26
27    if (.not.allocated (A)) then
28      allocate (A, source = AA (2, foo))
29    endif
30
31    select type (A)
32      type is (AA)
33        foo = AA (3, foo)
34        A = AA (4, NULL ())
35    end select
36  end function
37end
38