| 1 |
! { dg-do run } |
| 2 |
! { dg-additional-sources pr32627_driver.c } |
| 3 |
! Verify that c_f_pointer exists for string arguments. |
| 4 |
program main |
| 5 |
use iso_c_binding |
| 6 |
implicit none |
| 7 |
interface |
| 8 |
function get_c_string() bind(c) |
| 9 |
use, intrinsic :: iso_c_binding, only: c_ptr |
| 10 |
type(c_ptr) :: get_c_string |
| 11 |
end function get_c_string |
| 12 |
end interface |
| 13 |
|
| 14 |
type, bind( c ) :: A |
| 15 |
integer( c_int ) :: xc, yc |
| 16 |
type( c_ptr ) :: str |
| 17 |
end type |
| 18 |
type( c_ptr ) :: x |
| 19 |
type( A ), pointer :: fptr |
| 20 |
type( A ), target :: my_a_type |
| 21 |
character( len=8 ), pointer :: strptr |
| 22 |
|
| 23 |
fptr => my_a_type |
| 24 |
|
| 25 |
fptr%str = get_c_string() |
| 26 |
|
| 27 |
call c_f_pointer( fptr%str, strptr ) |
| 28 |
|
| 29 |
print *, 'strptr is: ', strptr |
| 30 |
end program main |
| 31 |
|
| 32 |
|