| 1 |
! { dg-do compile } |
| 2 |
! { dg-options "-std=f2008" } |
| 3 |
! |
| 4 |
! Check relaxed TS29113 constraints for procedures |
| 5 |
! and c_f_*pointer argument checking for c_ptr/c_funptr. |
| 6 |
! |
| 7 |
|
| 8 |
use iso_c_binding |
| 9 |
implicit none |
| 10 |
type(c_ptr) :: cp |
| 11 |
type(c_funptr) :: cfp |
| 12 |
|
| 13 |
interface |
| 14 |
subroutine sub() bind(C) |
| 15 |
end subroutine sub |
| 16 |
end interface |
| 17 |
integer(c_int), pointer :: int |
| 18 |
procedure(sub), pointer :: fsub |
| 19 |
|
| 20 |
integer, external :: noCsub |
| 21 |
procedure(integer), pointer :: fint |
| 22 |
|
| 23 |
cp = c_funloc (sub) ! { dg-error "Cannot convert TYPE.c_funptr. to TYPE.c_ptr." } |
| 24 |
cfp = c_loc (int) ! { dg-error "Cannot convert TYPE.c_ptr. to TYPE.c_funptr." } |
| 25 |
|
| 26 |
call c_f_pointer (cfp, int) ! { dg-error "Argument CPTR at .1. to C_F_POINTER shall have the type TYPE.C_PTR." } |
| 27 |
call c_f_procpointer (cp, fsub) ! { dg-error "Argument CPTR at .1. to C_F_PROCPOINTER shall have the type TYPE.C_FUNPTR." } |
| 28 |
|
| 29 |
cfp = c_funloc (noCsub) ! { dg-error "Fortran 2018: Noninteroperable procedure at .1. to C_FUNLOC" } |
| 30 |
call c_f_procpointer (cfp, fint) ! { dg-error "Fortran 2018: Noninteroperable procedure pointer at .1. to C_F_PROCPOINTER" } |
| 31 |
end |