summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/proc_ptr_comp_29.f90
blob: 94c59cd1a3bb3d4d5e254698834604bdd33ec725 (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
! { dg-do run }
!
! PR 47240: [F03] segfault with procedure pointer component
!
! Contributed by Martien Hulsen <m.a.hulsen@tue.nl>

  type t
    procedure (fun), pointer, nopass :: p
  end type
  type(t) :: x
  real, dimension(2) :: r
  x%p => fun
  r = evaluate (x%p)
  if (r(1) /= 5 .and. r(2) /= 6) call abort()
contains
  function fun ()
    real, dimension(2) :: fun
    fun = (/ 5, 6 /)
  end function
  function evaluate ( dummy )
    real, dimension(2) :: evaluate
    procedure(fun) :: dummy
    evaluate = dummy ()
  end function
end