Debian Codegraph @

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

raw
1 ! PR92482
2 ! { dg-do run }
3 ! { dg-additional-sources "fc-out-descriptor-5-c.c dump-descriptors.c" }
4 !
5 ! This program checks that you can call a C function declared with an
6 ! assumed-length character dummy from Fortran.
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 character(len=*,kind=C_CHAR), intent(out) :: a
16 end subroutine
17 end interface
18
19 character(len=26,kind=C_CHAR) :: aa
20 aa = 'abcdefghijklmnopqrstuvwxyz'
21
22 ! Test both passing the fixed-length-string directly to the function
23 ! with a C interface, and indirectly via a Fortran function with an
24 ! assumed-length dummy argument.
25 call ctest (aa)
26 call ftest (aa)
27
28 contains
29 subroutine ftest (a) bind (c)
30 use iso_c_binding
31 character(len=*,kind=C_CHAR), intent(out) :: a
32 call ctest (a)
33 end subroutine
34
35 end program