Debian Codegraph @

gcc/testsuite/gfortran.dg/c-interop/fc-descriptor-1-c.c

raw
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,-1:3)
17 Make sure that matches what's in the descriptor. Note that per
18 section 18.5.3 in the 2018 standard, for a nonallocatable nonpointer
19 array, the array dimensions in the descriptor reflect the shape of
20 the array rather than the actual bounds; the lower_bound is required
21 to be zero. */
22 if (!a->base_addr)
23 abort ();
24 if (a->elem_len != sizeof(int))
25 abort ();
26 if (a->rank != 2)
27 abort ();
28 if (a->type != CFI_type_int)
29 abort ();
30 if (a->attribute != CFI_attribute_other)
31 abort ();
32 if (a->dim[0].lower_bound != 0)
33 abort ();
34 if (a->dim[0].extent != 10)
35 abort ();
36 if (a->dim[0].sm != sizeof(int))
37 abort ();
38 if (a->dim[1].lower_bound != 0)
39 abort ();
40 if (a->dim[1].extent != 5)
41 abort ();
42 if (a->dim[1].sm != a->dim[0].extent * sizeof(int))
43 abort ();
44 if (!CFI_is_contiguous (a))
45 abort ();
46 }