(root)/
gcc-13.2.0/
gcc/
testsuite/
gfortran.dg/
c-interop/
fc-out-descriptor-6-c.c
       1  #include <stdlib.h>
       2  
       3  #include <ISO_Fortran_binding.h>
       4  #include "dump-descriptors.h"
       5  
       6  extern void ctest (CFI_cdesc_t *a);
       7  
       8  void
       9  ctest (CFI_cdesc_t *a)
      10  {
      11    /* Dump the descriptor contents to test that we can access the fields
      12       correctly, etc.  */
      13    dump_CFI_cdesc_t (a);
      14  
      15    /* The actual argument on the Fortran side was declared as 
      16         integer(C_INT) :: aa(10,5:8)
      17       but was passed via other functions that variously describe it as
      18       having size (10,*), (10,1:*), or (10,5:*) before calling this function
      19       with an assumed-rank array dummy.  But, the spec says:
      20  
      21         For a C descriptor of a nonallocatable nonpointer object, the
      22         value of the lower_bound member of each element of the dim member
      23         of the descriptor is zero.
      24  
      25         In a C descriptor of an assumed-size array, the extent member of
      26         the last element of the dim member has the value −1.  */
      27  
      28    if (!a->base_addr)
      29      abort ();
      30    if (a->elem_len != sizeof(int))
      31      abort ();
      32    if (a->rank != 2)
      33      abort ();
      34    if (a->type != CFI_type_int)
      35      abort ();
      36    if (a->attribute != CFI_attribute_other)
      37      abort ();
      38    if (a->dim[0].lower_bound != 0)
      39      abort ();
      40    if (a->dim[0].extent != 10)
      41      abort ();
      42    if (a->dim[0].sm != sizeof(int))
      43      abort ();
      44    if (a->dim[1].lower_bound != 0)
      45      abort ();
      46    if (a->dim[1].extent != -1)
      47      abort ();
      48    if (a->dim[1].sm != a->dim[0].extent * sizeof(int))
      49      abort ();
      50  }