summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/c_f_tests_driver.c
blob: 5079cf7990024b9f02a9e06ffad0c7c979bb5aa5 (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
57
58
59
60
61
62
63
64
65
66
extern void abort(void);

typedef struct myCDerived
{
   int cInt;
   double cDouble;
   float cFloat;
   short cShort;
   void *ptr;
}myCDerived_t;

#define DERIVED_ARRAY_LEN 10
#define ARRAY_LEN_2 3
#define DIM1 2
#define DIM2 3

void testDerivedPtrs(myCDerived_t *cDerivedPtr,
                     myCDerived_t *derivedArray, int arrayLen,
                     myCDerived_t *derived2d, int dim1, int dim2);

int main(int argc, char **argv)
{
   myCDerived_t cDerived;
   myCDerived_t derivedArray[DERIVED_ARRAY_LEN];
   myCDerived_t derived2DArray[DIM1][DIM2];
   int i = 0;
   int j = 0;

   cDerived.cInt = 1;
   cDerived.cDouble = 2.0;
   cDerived.cFloat = 3.0;
   cDerived.cShort = 4;
/*    cDerived.ptr = NULL; */
   /* nullify the ptr */
   cDerived.ptr = 0;

   for(i = 0; i < DERIVED_ARRAY_LEN; i++)
   {
      derivedArray[i].cInt = (i+1) * 1;
      derivedArray[i].cDouble = (i+1) * 1.0; /* 2.0; */
      derivedArray[i].cFloat = (i+1) * 1.0; /* 3.0; */
      derivedArray[i].cShort = (i+1) * 1; /* 4; */
/*       derivedArray[i].ptr = NULL; */
      derivedArray[i].ptr = 0;
   }

   for(i = 0; i < DIM1; i++)
   {
      for(j = 0; j < DIM2; j++)
      {
         derived2DArray[i][j].cInt = ((i*DIM1) * 1) + j;
         derived2DArray[i][j].cDouble = ((i*DIM1) * 1.0) + j;
         derived2DArray[i][j].cFloat = ((i*DIM1) * 1.0) + j;
         derived2DArray[i][j].cShort = ((i*DIM1) * 1) + j;
/*          derived2DArray[i][j].ptr = NULL; */
         derived2DArray[i][j].ptr = 0;
      }
   }

   /* send in the transpose size (dim2 is dim1, dim1 is dim2) */
   testDerivedPtrs(&cDerived, derivedArray, DERIVED_ARRAY_LEN,
                   derived2DArray[0], DIM2, DIM1);
   
   return 0;
}/* end main() */