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
ctest(CFI_cdesc_t * a)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:*). But, the spec says:
19
20 For a C descriptor of a nonallocatable nonpointer object, the
21 value of the lower_bound member of each element of the dim member
22 of the descriptor is zero.
23
24 In a C descriptor of an assumed-size array, the extent member of
25 the last element of the dim member has the value −1. */
26
27 if (!a->base_addr)
28 abort ();
29 if (a->elem_len != sizeof(int))
30 abort ();
31 if (a->rank != 2)
32 abort ();
33 if (a->type != CFI_type_int)
34 abort ();
35 if (a->attribute != CFI_attribute_other)
36 abort ();
37 if (a->dim[0].lower_bound != 0)
38 abort ();
39 if (a->dim[0].extent != 10)
40 abort ();
41 if (a->dim[0].sm != sizeof(int))
42 abort ();
43 if (a->dim[1].lower_bound != 0)
44 abort ();
45 if (a->dim[1].extent != -1)
46 abort ();
47 if (a->dim[1].sm != a->dim[0].extent * sizeof(int))
48 abort ();
49 }
50
51
52