| 1 |
! { dg-do compile } |
| 2 |
! PR fortran/110826 - procedure pointer component in DT array |
| 3 |
|
| 4 |
module m |
| 5 |
implicit none |
| 6 |
|
| 7 |
type pp |
| 8 |
procedure(func_template), pointer, nopass :: f =>null() |
| 9 |
end type pp |
| 10 |
|
| 11 |
abstract interface |
| 12 |
function func_template(state) result(dstate) |
| 13 |
implicit none |
| 14 |
real, dimension(:,:), intent(in) :: state |
| 15 |
real, dimension(size(state,1), size(state,2)) :: dstate |
| 16 |
end function |
| 17 |
end interface |
| 18 |
|
| 19 |
contains |
| 20 |
|
| 21 |
function zero_state(state) result(dstate) |
| 22 |
real, dimension(:,:), intent(in) :: state |
| 23 |
real, dimension(size(state,1), size(state,2)) :: dstate |
| 24 |
dstate = 0. |
| 25 |
end function zero_state |
| 26 |
|
| 27 |
end module m |
| 28 |
|
| 29 |
program test_func_array |
| 30 |
use m |
| 31 |
implicit none |
| 32 |
|
| 33 |
real, dimension(4,6) :: state |
| 34 |
type(pp) :: func_scalar |
| 35 |
type(pp) :: func_array(4) |
| 36 |
|
| 37 |
func_scalar %f => zero_state |
| 38 |
func_array(1)%f => zero_state |
| 39 |
print *, func_scalar %f(state) |
| 40 |
print *, func_array(1)%f(state) |
| 41 |
if (.not. all (shape (func_scalar %f(state)) == shape (state))) stop 1 |
| 42 |
if (.not. all (shape (func_array(1)%f(state)) == shape (state))) stop 2 |
| 43 |
end program test_func_array |