Debian Codegraph @

gcc/testsuite/gfortran.dg/c-interop/fc-descriptor-7-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 *, _Bool);
7
8 void
9 ctest (CFI_cdesc_t *a, _Bool is_cont)
10 {
11 CFI_index_t subscripts[2];
12 /* Dump the descriptor contents to test that we can access the fields
13 correctly, etc. */
14
15 #if DEBUG
16 dump_CFI_cdesc_t (a);
17 #endif
18
19 /* We expect to get an array of shape (5,10) that may not be
20 contiguous. */
21 if (!a->base_addr)
22 abort ();
23 if (a->elem_len != sizeof(int))
24 abort ();
25 if (a->rank != 2)
26 abort ();
27 if (a->type != CFI_type_int)
28 abort ();
29 if (a->attribute != CFI_attribute_other)
30 abort ();
31 if (a->dim[0].lower_bound != 0)
32 abort ();
33 if (a->dim[0].extent != 5)
34 abort ();
35 if (a->dim[1].lower_bound != 0)
36 abort ();
37 if (a->dim[1].extent != 10)
38 abort ();
39
40 if (is_cont != CFI_is_contiguous (a))
41 abort ();
42
43 if (abs (a->dim[0].sm) < a->elem_len)
44 abort ();
45
46 for (int j = 0; j < 5; ++j)
47 for (int i = 0; i < 10; ++i)
48 {
49 subscripts[0] = j; subscripts[1] = i;
50 if (*(int *) CFI_address (a, subscripts) != (i+1) + 100*(j+1))
51 abort ();
52 }
53 }