aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/c-interop/contiguous-1-c.c
blob: 6b30da48e5fab8ed02c5e2e108df5b4f6f97666c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdlib.h>

#include <ISO_Fortran_binding.h>
#include "dump-descriptors.h"

extern void ctest1 (CFI_cdesc_t *a);
extern void ctest2 (CFI_cdesc_t *a);

static void
ctest (CFI_cdesc_t *a)
{
  int i;
  int *p;

  /* Dump the descriptor contents to test that we can access the fields
     correctly, etc.  */
  dump_CFI_cdesc_t (a);

  /* Make sure we got a valid descriptor.  */
  if (!a->base_addr)
    abort ();
  if (a->elem_len != sizeof(int))
    abort ();
  if (a->rank != 1)
    abort ();
  if (a->type != CFI_type_int)
    abort ();
  if (a->attribute != CFI_attribute_other)
    abort ();
  if (a->dim[0].sm != sizeof(int))
    abort ();
  if (!CFI_is_contiguous (a))
    abort ();

  /* Negate the elements of the array.  */
  p = (int *)a->base_addr;
  for (i = 0; i < a->dim[0].extent; i++)
    p[i] = -p[i];
}


/* The two entry points are declared differently on the C side, but both
   should do the same thing.  */

void
ctest1 (CFI_cdesc_t *a)
{
  ctest (a);
}

void
ctest2 (CFI_cdesc_t *a)
{
  ctest (a);
}