| 1 |
! PR92482 |
| 2 |
! { dg-do run } |
| 3 |
! { dg-additional-sources "cf-descriptor-5-c.c dump-descriptors.c" } |
| 4 |
! { dg-additional-options "-g" } |
| 5 |
! |
| 6 |
! This program checks that building a descriptor for a character object |
| 7 |
! in C works and that you can use it to call back into a Fortran function |
| 8 |
! with an assumed-length dummy that is declared with C binding. |
| 9 |
|
| 10 |
subroutine ftest (a, n) bind (c, name="ftest") |
| 11 |
use iso_c_binding |
| 12 |
character(kind=C_CHAR, len=*) :: a |
| 13 |
integer(C_INT), value :: n |
| 14 |
|
| 15 |
if (len (a) .ne. n) stop 101 |
| 16 |
end subroutine |
| 17 |
|
| 18 |
program testit |
| 19 |
use iso_c_binding |
| 20 |
implicit none |
| 21 |
|
| 22 |
interface |
| 23 |
subroutine ctest (n) bind (c) |
| 24 |
use iso_c_binding |
| 25 |
integer(C_INT), value :: n |
| 26 |
end subroutine |
| 27 |
end interface |
| 28 |
|
| 29 |
call ctest (42) |
| 30 |
|
| 31 |
end program |