| 1 |
! PR92482 |
| 2 |
! { dg-do run } |
| 3 |
! { dg-additional-sources "fc-descriptor-5-c.c dump-descriptors.c" } |
| 4 |
! { dg-additional-options "-g" } |
| 5 |
! |
| 6 |
! This program tests it works to call a C function from Fortran with |
| 7 |
! an assumed length character dummy. |
| 8 |
|
| 9 |
program testit |
| 10 |
use iso_c_binding |
| 11 |
implicit none |
| 12 |
|
| 13 |
interface |
| 14 |
subroutine ctest (a) bind (c) |
| 15 |
use iso_c_binding |
| 16 |
character(len=*,kind=C_CHAR) :: a |
| 17 |
end subroutine |
| 18 |
end interface |
| 19 |
|
| 20 |
character(len=20,kind=C_CHAR) :: aa |
| 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) |
| 30 |
use iso_c_binding |
| 31 |
character(len=*,kind=C_CHAR) :: a |
| 32 |
call ctest (a) |
| 33 |
end subroutine |
| 34 |
|
| 35 |
end program |