blob: 5a3f9e5f8760b3b5c727e8ef829ffd1f3264c8ef (
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
|
/* APPLE LOCAL file 4430139 */
extern void abort();
#include <string.h>
/* This is bitreverse-18 with d and e switched.
Note that this changes the layout and even the size. */
/* { dg-do run { target powerpc*-*-darwin* } } */
/* { dg-options "-std=gnu99" } */
typedef unsigned short WORD;
typedef unsigned int DWORD;
#pragma reverse_bitfields on
#define USE_STRUCT_WRAPPER 0
#pragma pack(push, 2)
typedef struct
{
DWORD a;
#if USE_STRUCT_WRAPPER
struct {
#endif
WORD b:2,
c:14;
#if USE_STRUCT_WRAPPER
};
#endif
DWORD d:10,
e:22;
DWORD f;
DWORD g:25,
h:1,
i:6;
#if USE_STRUCT_WRAPPER
struct {
#endif
WORD j:14,
k:2;
#if USE_STRUCT_WRAPPER
};
#endif
} Foo;
typedef union { Foo x; int y[6]; } u1;
#pragma pack(pop)
int main(int argc, char* argv[])
{
Foo foo;
int i;
u1 U;
memset (&U, 0, sizeof(u1));
U.x.a = 1;
U.x.b = 1;
U.x.c = 1;
U.x.d = 1;
U.x.e = 1;
U.x.f = 1;
U.x.g = 1;
U.x.h = 1;
U.x.i = 1;
U.x.j = 1;
U.x.k = 1;
int s = sizeof(Foo);
if (sizeof(Foo) != 22
|| U.y[0] != 0x00000001
|| U.y[1] != 0x00010000
|| U.y[2] != 0x00000001
|| U.y[3] != 0x00000001
|| U.y[4] != 0x06000001
|| U.y[5] != 0x40010000)
abort();
return 0;
}
|