aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/c-interop/fc-descriptor-3.f90
blob: c65cb7a3944c2793388ce31fd6350602517fc118 (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
37
! PR 101308
! { dg-do run }
! { dg-additional-sources "fc-descriptor-3-c.c dump-descriptors.c" }
! { dg-additional-options "-g" }
!
! This program tests that pointer and allocatable scalar 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)
  bb => aa
  call ctest (aa, bb, 1)

end program