2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / g++.dg / opt / 20050511-1.C
bloba8929030af4e1fb783e77348f8b7f0b9b72df6fb
1 /* { dg-do run } */
2 /* { dg-options "-w" } */
3 /* { dg-options "-O3 -w" { target powerpc*-*-* } } */
4 #include <stdio.h>
5 #include <stdlib.h>
7 // The VxWorks kernel headers define their own UINT32
8 #if defined __vxworks && !defined __RTP__
9 #define UINT32 my_UINT32
10 #endif
12 typedef signed short SINT16 ;
13 typedef unsigned long UINT32 ;
14 typedef unsigned int UINT ;
16 class A
18 public:
19     union   
20     {
21       SINT16 xy[2];
22       UINT32 abXY;
23     };
24   bool operator==(const A& other) const {return abXY == other.abXY;}
25   bool operator!=(const A& other) const {return abXY != other.abXY;}
28 template <int size> struct pArray { unsigned char u08[16*(((size*1)+15)/16)] __attribute__ ((aligned(16))); };
30 struct B
32   union {
33     A mvL[2];
34     pArray<1> xyz;
35   };
36 } ;
38 typedef struct
40   UINT w;
41   B b;
43 }C;
46 UINT32 bar (const C * sPtr)
48   UINT w = sPtr->w;
49   A a;
51   a.xy[0] = sPtr->b.mvL[w].xy[0]<<2;
52   a.xy[1] = sPtr->b.mvL[w].xy[1]<<2;
54   if (a.xy[0] != ((SINT16) 0xffff << 2))
55         abort ();
58 int main()
60         A a;
61         C c;
62         a.xy[0] = 0xffff;
63         a.xy[1] = 0xffff;
64         c.w=0;
65         c.b.mvL[0].xy[0] = a.xy[0];
66         c.b.mvL[0].xy[1] = a.xy[1];
68         bar (&c);
70