Debian Codegraph @

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

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