Debian Codegraph @

gcc/testsuite/gfortran.dg/c-interop/fc-descriptor-3.f90

raw
1 ! PR 101308
2 ! { dg-do run }
3 ! { dg-additional-sources "fc-descriptor-3-c.c dump-descriptors.c" }
4 ! { dg-additional-options "-g" }
5 !
6 ! This program tests that pointer and allocatable scalar arguments are
7 ! correctly passed by descriptor from Fortran code into C.
8
9 program testit
10 use iso_c_binding
11 implicit none
12
13 type, bind (c) :: m
14 real(C_DOUBLE) :: a(3, 3)
15 end type
16
17 interface
18 subroutine ctest (a, b, initp) bind (c)
19 use iso_c_binding
20 import m
21 type(m), allocatable :: a
22 type(m), pointer :: b
23 integer(C_INT), value :: initp
24 end subroutine
25 end interface
26
27 type (m), allocatable, target :: aa
28 type (m), pointer :: bb
29
30 ! Test both before and after allocation/pointer initialization.
31 bb => null()
32 call ctest (aa, bb, 0)
33 allocate (aa)
34 bb => aa
35 call ctest (aa, bb, 1)
36
37 end program