| 1 |
! PR 92482 |
| 2 |
! { dg-do run } |
| 3 |
! |
| 4 |
! TS 29113 |
| 5 |
! 8.7 Interoperability of procedures and procedure interfaces |
| 6 |
! |
| 7 |
! If a dummy argument in an interoperable interface is of type |
| 8 |
! CHARACTER and is allocatable or a pointer, its character length shall |
| 9 |
! be deferred. |
| 10 |
|
| 11 |
program testit |
| 12 |
use iso_c_binding |
| 13 |
|
| 14 |
character (kind=C_CHAR, len=:), allocatable :: aa |
| 15 |
character (kind=C_CHAR, len=:), pointer :: pp |
| 16 |
|
| 17 |
|
| 18 |
pp => NULL () |
| 19 |
|
| 20 |
call frobf (aa, pp) |
| 21 |
if (.not. allocated (aa)) stop 101 |
| 22 |
if (aa .ne. 'foo') stop 102 |
| 23 |
if (.not. associated (pp)) stop 103 |
| 24 |
if (pp .ne. 'bar') stop 104 |
| 25 |
|
| 26 |
pp => NULL () |
| 27 |
|
| 28 |
call frobc (aa, pp) |
| 29 |
if (.not. allocated (aa)) stop 101 |
| 30 |
if (aa .ne. 'frog') stop 102 |
| 31 |
if (.not. associated (pp)) stop 103 |
| 32 |
if (pp .ne. 'toad') stop 104 |
| 33 |
|
| 34 |
|
| 35 |
contains |
| 36 |
|
| 37 |
subroutine frobf (a, p) |
| 38 |
use iso_c_binding |
| 39 |
character (kind=C_CHAR, len=:), allocatable :: a |
| 40 |
character (kind=C_CHAR, len=:), pointer :: p |
| 41 |
allocate (character(len=3) :: p) |
| 42 |
a = 'foo' |
| 43 |
p = 'bar' |
| 44 |
end subroutine |
| 45 |
|
| 46 |
subroutine frobc (a, p) bind (c) |
| 47 |
use iso_c_binding |
| 48 |
character (kind=C_CHAR, len=:), allocatable :: a |
| 49 |
character (kind=C_CHAR, len=:), pointer :: p |
| 50 |
allocate (character(len=4) :: p) |
| 51 |
a = 'frog' |
| 52 |
p = 'toad' |
| 53 |
end subroutine |
| 54 |
|
| 55 |
end program |