Update ChangeLog and version files for release
[official-gcc.git] / gcc / testsuite / c-c++-common / torture / vector-subscript-2.c
blob202b3d95a66dfcf987abd565714184fa1648c897
1 /* { dg-do run } */
2 /* { dg-options "-fno-common" { target hppa*-*-hpux* } } */
3 #define vector __attribute__((vector_size(sizeof(int)*4) ))
5 /* Check to make sure that we extract and insert the vector at the same
6 location for vector subscripting (with constant indexes) and
7 that vectors layout are the same as arrays. */
9 struct TV4
11 vector int v;
14 typedef struct TV4 MYV4;
16 static inline MYV4 myfunc2( int x, int y, int z, int w )
18 MYV4 temp;
19 temp.v[0] = x;
20 temp.v[1] = y;
21 temp.v[2] = z;
22 temp.v[3] = w;
23 return temp;
25 MYV4 val3;
26 __attribute__((noinline)) void modify (void)
28 val3 = myfunc2( 1, 2, 3, 4 );
30 int main( int argc, char* argv[] )
32 int a[4];
33 int i;
35 /* Set up the vector. */
36 modify();
38 /* Check the vector via the global variable. */
39 if (val3.v[0] != 1)
40 __builtin_abort ();
41 if (val3.v[1] != 2)
42 __builtin_abort ();
43 if (val3.v[2] != 3)
44 __builtin_abort ();
45 if (val3.v[3] != 4)
46 __builtin_abort ();
48 vector int a1 = val3.v;
50 /* Check the vector via a local variable. */
51 if (a1[0] != 1)
52 __builtin_abort ();
53 if (a1[1] != 2)
54 __builtin_abort ();
55 if (a1[2] != 3)
56 __builtin_abort ();
57 if (a1[3] != 4)
58 __builtin_abort ();
60 __builtin_memcpy(a, &val3, sizeof(a));
61 /* Check the vector via copying it to an array. */
62 for(i = 0; i < 4; i++)
63 if (a[i] != i+1)
64 __builtin_abort ();
67 return 0;