struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20090113-1.c
blob6e835c6c1d2f220d79a11720f94de75dfbe10f2a
1 /*
2 20090113-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
12 typedef struct descriptor_dimension
14 int stride;
15 int lbound;
16 int ubound;
17 } descriptor_dimension;
18 typedef struct {
19 int *data;
20 int dtype;
21 descriptor_dimension dim[7];
22 } gfc_array_i4;
24 void
25 msum_i4 (gfc_array_i4 * const retarray,
26 gfc_array_i4 * const array,
27 const int * const pdim)
29 int count[7];
30 int extent[7];
31 int * dest;
32 const int * base;
33 int dim;
34 int n;
35 int len;
37 dim = (*pdim) - 1;
38 len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
40 for (n = 0; n < dim; n++)
42 extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
43 count[n] = 0;
46 dest = retarray->data;
47 base = array->data;
51 int result = 0;
53 for (n = 0; n < len; n++, base++)
54 result += *base;
55 *dest = result;
57 count[0]++;
58 dest += 1;
60 while (count[0] != extent[0]);
62 #endif
64 void
65 testTortureExecute (void)
67 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
68 int rdata[3];
69 int adata[9];
70 gfc_array_i4 retarray = { rdata, 265, { { 1, 1, 3 } } };
71 gfc_array_i4 array = { adata, 266, { { 1, 1, 3 }, { 3, 1, 3 } } };
72 int dim = 2;
73 msum_i4 (&retarray, &array, &dim);
74 return;
75 #endif