Debian Codegraph @

gcc/testsuite/gfortran.dg/bind_c_array_params_3.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-sources bind_c_array_params_3_aux.c }
3 !
4 ! PR fortran/92284
5 !
6 ! Contributed by José Rui Faustino de Sousa
7 !
8 program arr_p
9 use, intrinsic :: iso_c_binding, only: c_int
10 implicit none (type, external)
11
12 integer(kind=c_int), pointer :: arr(:)
13 integer :: i
14
15 nullify(arr)
16 call arr_set(arr)
17
18 if (.not.associated(arr)) stop 1
19 if (lbound(arr,dim=1) /= 1) stop 2
20 if (ubound(arr,dim=1) /= 9) stop 3
21 if (any (arr /= [(i, i=0,8)])) stop 4
22 deallocate(arr)
23
24 contains
25
26 subroutine arr_set(this) !bind(c)
27 integer(kind=c_int), pointer, intent(out) :: this(:)
28
29 interface
30 subroutine arr_set_c(this) bind(c)
31 use, intrinsic :: iso_c_binding, only: c_int
32 implicit none
33 integer(kind=c_int), pointer, intent(out) :: this(:)
34 end subroutine arr_set_c
35 end interface
36
37 call arr_set_c(this)
38 end subroutine arr_set
39 end program arr_p