OSDN Git Service

Backported from mainline
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.c-torture / execute / 20050316-3.c
1 extern void abort (void);
2
3 typedef int V2SI __attribute__ ((vector_size (8)));
4 typedef unsigned int V2USI __attribute__ ((vector_size (8)));
5 typedef short V2HI __attribute__ ((vector_size (4)));
6 typedef unsigned int V2UHI __attribute__ ((vector_size (4)));
7
8 V2USI
9 test1 (V2SI x)
10 {
11   return (V2USI) (V2SI) (long long) x;
12 }
13
14 long long
15 test2 (V2SI x)
16 {
17   return (long long) (V2USI) (V2SI) (long long) x;
18 }
19
20 int
21 main (void)
22 {
23   if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8)
24     return 0;
25
26   union { V2SI x; int y[2]; V2USI z; long long l; } u;
27   V2SI a = { -3, -3 };
28   u.z = test1 (a);
29   if (u.y[0] != -3 || u.y[1] != -3)
30     abort ();
31
32   u.l = test2 (a);
33   if (u.y[0] != -3 || u.y[1] != -3)
34     abort ();
35   return 0;
36 }