summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/20050511-1.C
blob: a8929030af4e1fb783e77348f8b7f0b9b72df6fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* { dg-do run } */
/* { dg-options "-w" } */
/* { dg-options "-O3 -w" { target powerpc*-*-* } } */
#include <stdio.h>
#include <stdlib.h>

// The VxWorks kernel headers define their own UINT32
#if defined __vxworks && !defined __RTP__
#define UINT32 my_UINT32
#endif

typedef signed short SINT16 ;
typedef unsigned long UINT32 ;
typedef unsigned int UINT ;

class A
{
public:
    union   
    {
      SINT16 xy[2];
      UINT32 abXY;
    };
  bool operator==(const A& other) const {return abXY == other.abXY;}
  bool operator!=(const A& other) const {return abXY != other.abXY;}
};

template <int size> struct pArray { unsigned char u08[16*(((size*1)+15)/16)] __attribute__ ((aligned(16))); };

struct B
{
  union {
    A mvL[2];
    pArray<1> xyz;
  };
} ;

typedef struct
{
  UINT w;
  B b;

}C;


UINT32 bar (const C * sPtr)
{
  UINT w = sPtr->w;
  A a;

  a.xy[0] = sPtr->b.mvL[w].xy[0]<<2;
  a.xy[1] = sPtr->b.mvL[w].xy[1]<<2;

  if (a.xy[0] != ((SINT16) 0xffff << 2))
	abort ();
}

int main()
{
	A a;
	C c;
	a.xy[0] = 0xffff;
	a.xy[1] = 0xffff;
	c.w=0;
	c.b.mvL[0].xy[0] = a.xy[0];
	c.b.mvL[0].xy[1] = a.xy[1];

	bar (&c);
}