| 1 |
! PR92482 |
| 2 |
! { dg-do compile } |
| 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 |
! This test checks that this error is diagnosed and is supposed to fail. |
| 12 |
|
| 13 |
module m |
| 14 |
use iso_c_binding |
| 15 |
|
| 16 |
interface |
| 17 |
|
| 18 |
! These are supposed to be OK |
| 19 |
subroutine good1 (x, n) bind (c) |
| 20 |
use iso_c_binding |
| 21 |
character (kind=C_CHAR, len=:), allocatable :: x |
| 22 |
integer(C_INT), value :: n |
| 23 |
end subroutine |
| 24 |
subroutine good2 (x, n) bind (c) |
| 25 |
use iso_c_binding |
| 26 |
character (kind=C_CHAR, len=:), pointer :: x |
| 27 |
integer(C_INT), value :: n |
| 28 |
end subroutine |
| 29 |
|
| 30 |
! These are supposed to fail. |
| 31 |
subroutine bad1 (x, n) bind (c) ! { dg-error "must have deferred length" } |
| 32 |
use iso_c_binding |
| 33 |
character (kind=C_CHAR, len=*), allocatable :: x |
| 34 |
integer(C_INT), value :: n |
| 35 |
end subroutine |
| 36 |
subroutine bad2 (x, n) bind (c) ! { dg-error "must have deferred length" } |
| 37 |
use iso_c_binding |
| 38 |
character (kind=C_CHAR, len=*), pointer :: x |
| 39 |
integer(C_INT), value :: n |
| 40 |
end subroutine |
| 41 |
|
| 42 |
subroutine bad3 (x, n) bind (c) ! { dg-error "must have deferred length" } |
| 43 |
use iso_c_binding |
| 44 |
character (kind=C_CHAR, len=80), allocatable :: x |
| 45 |
integer(C_INT), value :: n |
| 46 |
end subroutine |
| 47 |
subroutine bad4 (x, n) bind (c) ! { dg-error "must have deferred length" } |
| 48 |
use iso_c_binding |
| 49 |
character (kind=C_CHAR, len=80), pointer :: x |
| 50 |
integer(C_INT), value :: n |
| 51 |
end subroutine |
| 52 |
|
| 53 |
subroutine bad5 (x, n) bind (c) ! { dg-error "must have deferred length" } |
| 54 |
use iso_c_binding |
| 55 |
character (kind=C_CHAR, len=1), allocatable :: x |
| 56 |
integer(C_INT), value :: n |
| 57 |
end subroutine |
| 58 |
subroutine bad6 (x, n) bind (c) ! { dg-error "must have deferred length" } |
| 59 |
use iso_c_binding |
| 60 |
character (kind=C_CHAR, len=1), pointer :: x |
| 61 |
integer(C_INT), value :: n |
| 62 |
end subroutine |
| 63 |
|
| 64 |
subroutine bad7 (x, n) bind (c) ! { dg-error "must have deferred length" } |
| 65 |
use iso_c_binding |
| 66 |
character (kind=C_CHAR), allocatable :: x |
| 67 |
integer(C_INT), value :: n |
| 68 |
end subroutine |
| 69 |
subroutine bad8 (x, n) bind (c) ! { dg-error "must have deferred length" } |
| 70 |
use iso_c_binding |
| 71 |
character (kind=C_CHAR), pointer :: x |
| 72 |
integer(C_INT), value :: n |
| 73 |
end subroutine |
| 74 |
end interface |
| 75 |
|
| 76 |
end module |