aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.apple/bitreverse-26.c
blob: e65b5da12627e70ff9464d71eec0d630a41ac08b (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
71
72
73
74
75
76
77
78
79
80
81
/* APPLE LOCAL file 4431496 */
extern void abort();
/* { dg-do run { target powerpc*-*-darwin* } } */
/* { dg-options "-std=gnu99" } */
#pragma reverse_bitfields on
#pragma ms_struct on

#pragma pack(push,1)
typedef struct _S2
{
 unsigned char c ;
 unsigned short s1 : 9;
 unsigned short s2 : 7;
} S2;

#pragma pack(pop)

union U2 { S2 ss; int x[3]; };

int TestS2(void)
{
 union U2 u = {0};
 u.ss.c = 0x15;
 u.ss.s1 = 0x15;
 u.ss.s2 = 0x15;
 
 if (sizeof(S2) != 3 || u.x[0] != 0x152a1500)
    abort();
  return 0;
}

#pragma pack(push,2)
typedef struct _S3
{
 unsigned char c ;
 unsigned short s1 : 9;
 unsigned short s2 : 7;
} S3;

#pragma pack(pop)

union U3 { S3 ss; int x[3]; };

int TestS3(void)
{
 union U3 u = {0};
 u.ss.c = 0x15;
 u.ss.s1 = 0x15;
 u.ss.s2 = 0x15;
 
 if (sizeof(S3) != 4 || u.x[0] != 0x15002a15)
    abort();
  return 0;
}

typedef struct _S4
{
 unsigned char c ;
 unsigned short s1 : 9;
 unsigned short s2 : 7;
} S4;


union U4 { S4 ss; int x[3]; };

int TestS4(void)
{
 union U4 u = {0};
 u.ss.c = 0x15;
 u.ss.s1 = 0x15;
 u.ss.s2 = 0x15;
 
 if (sizeof(S4) != 4 || u.x[0] != 0x15002a15)
    abort();
  return 0;
}

int main()
{
 return TestS2() + TestS3() + TestS4();
}