| 1 |
! PR92482 |
| 2 |
! { dg-do run } |
| 3 |
! { dg-additional-sources "cf-out-descriptor-5-c.c dump-descriptors.c" } |
| 4 |
! { dg-additional-options "-g" } |
| 5 |
! |
| 6 |
! This program checks use of an assumed-length character dummy argument |
| 7 |
! as an intent(out) parameter in subroutines with C binding. |
| 8 |
|
| 9 |
subroutine ftest (a, n) bind (c, name="ftest") |
| 10 |
use iso_c_binding |
| 11 |
character(kind=C_CHAR, len=*), intent(out) :: a |
| 12 |
integer(C_INT), value :: n |
| 13 |
|
| 14 |
if (len (a) .ne. n) stop 101 |
| 15 |
a = 'abcdefghijklmnopqrstuvwxyz' |
| 16 |
end subroutine |
| 17 |
|
| 18 |
program testit |
| 19 |
use iso_c_binding |
| 20 |
implicit none |
| 21 |
|
| 22 |
interface |
| 23 |
subroutine ctest (a, n) bind (c) |
| 24 |
use iso_c_binding |
| 25 |
character(kind=C_CHAR, len=*), intent(out) :: a |
| 26 |
integer(C_INT), value :: n |
| 27 |
end subroutine |
| 28 |
|
| 29 |
subroutine ftest (a, n) bind (c) |
| 30 |
use iso_c_binding |
| 31 |
character(kind=C_CHAR, len=*), intent(out) :: a |
| 32 |
integer(C_INT), value :: n |
| 33 |
end subroutine |
| 34 |
end interface |
| 35 |
|
| 36 |
character(kind=C_CHAR, len=42) :: aa |
| 37 |
|
| 38 |
! call ftest directly |
| 39 |
aa = '12345678910' |
| 40 |
call ftest (aa, 42) |
| 41 |
print *, aa |
| 42 |
|
| 43 |
! ctest calls ftest indirectly |
| 44 |
aa = '12345678910' |
| 45 |
call ctest (aa, 42) |
| 46 |
print *, aa |
| 47 |
|
| 48 |
end program |