Debian Codegraph @

gcc/testsuite/g++.dg/opt/20050511-1.C

raw
1 /* { dg-do run } */
2 /* { dg-options "-w" } */
3 /* { dg-options "-O3 -w" { target powerpc*-*-* } } */
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 // The VxWorks kernel headers define their own UINT32
8 #if defined __vxworks
9 #define UINT32 my_UINT32
10 #endif
11
12 typedef signed short SINT16 ;
13 typedef unsigned long UINT32 ;
14 typedef unsigned int UINT ;
15
16 class A
17 {
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;}
26 };
27
28 template <int size> struct pArray { unsigned char u08[16*(((size*1)+15)/16)] __attribute__ ((aligned(16))); };
29
30 struct B
31 {
32 union {
33 A mvL[2];
34 pArray<1> xyz;
35 };
36 } ;
37
38 typedef struct
39 {
40 UINT w;
41 B b;
42
43 }C;
44
45
46 UINT32 bar (const C * sPtr)
47 {
48 UINT w = sPtr->w;
49 A a;
50
51 a.xy[0] = sPtr->b.mvL[w].xy[0]<<2;
52 a.xy[1] = sPtr->b.mvL[w].xy[1]<<2;
53
54 if (a.xy[0] != ((SINT16) 0xffff << 2))
55 abort ();
56
57 return 0;
58 }
59
60 int main()
61 {
62 A a;
63 C c;
64 a.xy[0] = 0xffff;
65 a.xy[1] = 0xffff;
66 c.w=0;
67 c.b.mvL[0].xy[0] = a.xy[0];
68 c.b.mvL[0].xy[1] = a.xy[1];
69
70 bar (&c);
71 }
72