aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/c-interop/fc-descriptor-2.f90
blob: ec90735aacaee9ed3c44ef7dfcfc6ecb7b051cc3 (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
38
39
40
! { dg-do run }
! { dg-additional-sources "fc-descriptor-2-c.c dump-descriptors.c" }
! { dg-additional-options "-g" }
!
! This program checks that a C function declared to take an assumed-rank
! array argument can be called from Fortran, and receives a correct
! descriptor.

program testit
  use iso_c_binding
  implicit none

  interface
    subroutine ctest (a, n) bind (c)
      use iso_c_binding
      real(C_FLOAT) :: a(..)
      integer(C_INT), value :: n
    end subroutine
  end interface

  real(C_FLOAT) :: aa(100)
  real(C_FLOAT) :: bb(3,4,5)

  ! Test both passing the fixed-size array directly to the function
  ! with a C interface, and indirectly via a Fortran function with an
  ! assumed-rank dummy argument.
  call ctest (aa, 1)
  call ctest (bb, 3)
  call ftest (aa, 1)
  call ftest (bb, 3)

contains
  subroutine ftest (a, n)
    use iso_c_binding
    real(C_FLOAT) :: a(..)
    integer, value :: n
    call ctest (a, n)
  end subroutine

end program