Debian Codegraph @

gcc/testsuite/gfortran.dg/c-interop/fc-out-descriptor-6.f90

raw
1 ! Reported as pr94070.
2 ! { dg-do run }
3 ! { dg-additional-sources "fc-out-descriptor-6-c.c dump-descriptors.c" }
4 ! { dg-additional-options "-g" }
5 !
6 ! This program checks passing an assumed-size array argument via descriptor
7 ! from Fortran to C.
8
9 program testit
10 use iso_c_binding
11 implicit none
12
13 ! Assumed-size arrays are not passed by descriptor. What we'll do
14 ! for this test function is bind an assumed-rank dummy to an
15 ! assumed-size array. This is supposed to fill in the descriptor
16 ! with information about the array present at the call site.
17 interface
18 subroutine ctest (a) bind (c)
19 use iso_c_binding
20 integer(C_INT), intent(out) :: a(..)
21 end subroutine
22 end interface
23
24 integer(C_INT), target :: aa(10,5:8)
25
26 ! To get an assumed-size array descriptor, we have to first pass the
27 ! fixed-size array to a Fortran function with an assumed-size dummy.
28 call ftest1 (aa)
29 call ftest2 (aa)
30 call ftest3 (aa)
31
32 contains
33 subroutine ftest1 (a)
34 use iso_c_binding
35 integer(C_INT) :: a(10,*)
36 call ctest (a)
37 end subroutine
38 subroutine ftest2 (a)
39 use iso_c_binding
40 integer(C_INT) :: a(10,5:*)
41 call ctest (a)
42 end subroutine
43 subroutine ftest3 (a)
44 use iso_c_binding
45 integer(C_INT) :: a(10,1:*)
46 call ctest (a)
47 end subroutine
48
49 end program