Implement C _FloatN, _FloatNx types.
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / matrix-6.c
blobe01e5311cd8c7a480b10bcc804f4e97861d02be0
1 /* { dg-do run } */
2 /* { dg-options "-fwhole-program" } */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <math.h>
8 #include <string.h>
10 void mem_init (void);
11 int ARCHnodes, ARCHnodes1;
12 int ***vel;
14 /* The last dimension of VEL escapes because of
15 the assignment : *vel[1] =...
16 Only the two external dimensions are flattened. */
18 /*--------------------------------------------------------------------------*/
20 int
21 main (int argc, char **argv)
23 int i, j, k;
25 ARCHnodes = 2;
26 ARCHnodes1 = 4;
28 /* Dynamic memory allocations and initializations */
30 mem_init ();
32 for (i = 0; i < ARCHnodes; i++)
34 for (j = 0; j < 3; j++)
36 for (k = 0; k < ARCHnodes1; k++)
37 printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
38 printf ("\n");
40 printf ("\n");
42 for (i = 0; i < ARCHnodes; i++)
43 for (j = 0; j < 3; j++)
44 if (!(i == 1 && j == 0))
45 free (vel[i][j]);
47 for (i = 0; i < ARCHnodes; i++)
48 free (vel[i]);
50 free (vel);
51 return 0;
54 /*--------------------------------------------------------------------------*/
55 /* Dynamic memory allocations and initializations */
57 void
58 mem_init (void)
61 int i, j, k,d;
63 d = 0;
64 vel = (int ***) malloc (ARCHnodes * sizeof (int **));
66 for (i = 0; i < ARCHnodes; i++)
68 vel[i] = (int **) malloc (3 * sizeof (int *));
69 if (vel[i] == (int **) NULL)
71 printf ("malloc failed for vel[%d]\n", i);
72 exit (0);
75 for (i = 0; i < ARCHnodes; i++)
77 for (j = 0; j < 3; j++)
79 vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
82 for (i = 0; i < ARCHnodes; i++)
84 for (j = 0; j < 3; j++)
86 for (k = 0; k < ARCHnodes1; k++)
88 vel[i][j][k] = d;
89 d++;
93 *vel[1] = &d;
96 /*--------------------------------------------------------------------------*/