Debian Codegraph @

gcc/testsuite/gfortran.dg/c-interop/removed-restrictions-1.f90

raw
1 ! { dg-do compile }
2 !
3 ! TS 29113
4 ! 8.1 Removed restrictions on ISO_C_BINDING module procedures
5 !
6 ! The subroutine C_F_POINTER from the intrinsic module ISO_C_BINDING has
7 ! the restriction in ISO/IEC 1539- 1:2010 that if FPTR is an array, it
8 ! shall be of interoperable type.
9 !
10 ! [...]
11 !
12 ! These restrictions are removed.
13
14 module m
15 use ISO_C_BINDING
16 implicit none
17
18 ! An obvious example of a type that isn't interoperable is a
19 ! derived type without a bind(c) clause.
20
21 integer :: buflen
22 parameter (buflen=256)
23
24 type :: packet
25 integer :: size
26 integer(1) :: buf(buflen)
27 end type
28
29 contains
30
31 subroutine test (ptr, n, packets)
32 type(C_PTR), intent(in) :: ptr
33 integer, intent(in) :: n
34 type(packet), pointer, intent(out) :: packets(:)
35
36 integer :: s(1)
37 s(1) = n
38
39 call c_f_pointer (ptr, packets, s)
40 end subroutine
41 end module