Debian Codegraph @

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

raw
1 ! { dg-do run }
2 ! { dg-additional-sources "fc-descriptor-1-c.c dump-descriptors.c" }
3 ! { dg-additional-options "-g" }
4 !
5 ! This checks that a C function declared to have an assumed-shape array
6 ! argument can be called from Fortran and receives a correct descriptor.
7
8 program testit
9 use iso_c_binding
10 implicit none
11
12 interface
13 subroutine ctest (a) bind (c)
14 use iso_c_binding
15 integer(C_INT) :: a(:,:)
16 end subroutine
17 end interface
18
19 integer(C_INT) :: aa(10,-1:3)
20
21 ! Test both passing the fixed-size array directly to the function
22 ! with a C interface, and indirectly via a Fortran function with an
23 ! assumed-shape dummy argument.
24 call ctest (aa)
25 call ftest (aa)
26
27 contains
28 subroutine ftest (a)
29 use iso_c_binding
30 integer(C_INT) :: a(:,:)
31 call ctest (a)
32 end subroutine
33
34 end program