aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/c-interop/fc-descriptor-4.f90
blob: db73dafe1d5b2db008a722914c0e0578115ab2fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
! { dg-do run }
! { dg-additional-sources "fc-descriptor-4-c.c dump-descriptors.c" }
! { dg-additional-options "-g" }
!
! This program tests that pointer and allocatable array arguments are 
! correctly passed by descriptor from Fortran code into C.

program testit
  use iso_c_binding
  implicit none

  type, bind (c) :: m
    real(C_DOUBLE) :: a(3, 3)
  end type

  interface
    subroutine ctest (a, b, initp) bind (c)
      use iso_c_binding
      import m
      type(m), allocatable :: a(:)
      type(m), pointer :: b(:)
      integer(C_INT), value :: initp
    end subroutine
  end interface

  type (m), allocatable, target :: aa(:)
  type (m), pointer :: bb(:)

  ! Test both before and after allocation/pointer initialization.
  bb => NULL ()
  call ctest (aa, bb, 0)
  allocate (aa(3:7))
  bb => aa
  call ctest (aa, bb, 1)

end program