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, CFI_cdesc_t *b, int initp);
7 
8 void
ctest(CFI_cdesc_t * a,CFI_cdesc_t * b,int initp)9 ctest (CFI_cdesc_t *a, CFI_cdesc_t *b, int initp)
10 {
11   /* Dump the descriptor contents to test that we can access the fields
12      correctly, etc.  */
13   dump_CFI_cdesc_t (a);
14   dump_CFI_cdesc_t (b);
15 
16   /* Make sure the descriptors match what we are expecting.  a is an
17      allocatable derived type object, b is a pointer which points at a
18      if initp is true.  */
19   if (initp && !a->base_addr)
20     abort ();
21   else if (!initp && a->base_addr)
22     abort ();
23   if (a->base_addr != b->base_addr)
24     abort ();
25 
26   if (a->rank != 0)
27     abort ();
28   if (b->rank != 0)
29     abort ();
30   if (a->type != CFI_type_struct)
31     abort ();
32   if (b->type != CFI_type_struct)
33     abort ();
34   if (a->elem_len != 3 * 3 * sizeof(double))
35     abort ();
36   if (b->elem_len != 3 * 3 * sizeof(double))
37     abort ();
38   if (a->attribute != CFI_attribute_allocatable)
39     abort ();
40   if (b->attribute != CFI_attribute_pointer)
41     abort ();
42 }
43