1 /* Test for MS structure sizes.  */
2 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
3 /* { dg-require-effective-target ilp32 } */
4 /* { dg-options "-std=gnu99" } */
5 
6 extern void abort ();
7 
8 #define ATTR __attribute__((__ms_struct__))
9 
10 #define size_struct_0 1
11 #define size_struct_1 4
12 #define size_struct_2 24
13 #define size_struct_3 8
14 #define size_struct_4 32
15 #define size_struct_5 12
16 #define size_struct_6 40
17 #define size_struct_7 8
18 #define size_struct_8 20
19 #define size_struct_9 32
20 
21 struct _struct_0
22 {
23   char member_0;
24 } ATTR;
25 typedef struct _struct_0 struct_0;
26 
27 struct _struct_1
28 {
29   char member_0;
30   short member_1:13;
31 } ATTR;
32 typedef struct _struct_1 struct_1;
33 
34 struct _struct_2
35 {
36   double member_0;
37   unsigned char member_1:8;
38   long member_2:32;
39   unsigned char member_3:5;
40   short member_4:14;
41   short member_5:13;
42   unsigned char:0;
43 } ATTR;
44 typedef struct _struct_2 struct_2;
45 
46 struct _struct_3
47 {
48   unsigned long member_0:26;
49   unsigned char member_1:2;
50 
51 } ATTR;
52 typedef struct _struct_3 struct_3;
53 
54 struct _struct_4
55 {
56   unsigned char member_0:7;
57   double member_1;
58   double member_2;
59   short member_3:5;
60   char member_4:2;
61 
62 } ATTR;
63 typedef struct _struct_4 struct_4;
64 
65 struct _struct_5
66 {
67   unsigned short member_0:12;
68   long member_1:1;
69   unsigned short member_2:6;
70 
71 } ATTR;
72 typedef struct _struct_5 struct_5;
73 
74 struct _struct_6
75 {
76   unsigned char member_0:7;
77   unsigned long member_1:25;
78   char member_2:1;
79   double member_3;
80   short member_4:9;
81   double member_5;
82 
83 } ATTR;
84 typedef struct _struct_6 struct_6;
85 
86 struct _struct_7
87 {
88   double member_0;
89 
90 } ATTR;
91 typedef struct _struct_7 struct_7;
92 
93 struct _struct_8
94 {
95   unsigned char member_0:7;
96   long member_1:11;
97   long member_2:5;
98   long:0;
99   char member_4:8;
100   unsigned short member_5:4;
101   unsigned char member_6:3;
102   long member_7:23;
103 
104 } ATTR;
105 typedef struct _struct_8 struct_8;
106 
107 struct _struct_9
108 {
109   double member_0;
110   unsigned long member_1:6;
111   long member_2:17;
112   double member_3;
113   unsigned long member_4:22;
114 
115 } ATTR;
116 typedef struct _struct_9 struct_9;
117 
118 struct_0 test_struct_0 = { 123 };
119 struct_1 test_struct_1 = { 82, 1081 };
120 struct_2 test_struct_2 = { 20.0, 31, 407760, 1, 14916, 6712 };
121 struct_3 test_struct_3 = { 64616999, 1 };
122 struct_4 test_struct_4 = { 61, 20.0, 20.0, 12, 0 };
123 struct_5 test_struct_5 = { 909, 1, 57 };
124 struct_6 test_struct_6 = { 12, 21355796, 0, 20.0, 467, 20.0 };
125 struct_7 test_struct_7 = { 20.0 };
126 struct_8 test_struct_8 = { 126, 1821, 22, 125, 6, 0, 2432638 };
127 struct_9 test_struct_9 = { 20.0, 3, 23957, 20.0, 1001631 };
128 
129 
130 int
main(void)131 main (void)
132 {
133 
134   if (size_struct_0 != sizeof (struct_0))
135     abort ();
136 
137   if (size_struct_1 != sizeof (struct_1))
138     abort ();
139 
140   if (size_struct_2 != sizeof (struct_2))
141     abort ();
142 
143   if (size_struct_3 != sizeof (struct_3))
144     abort ();
145 
146   if (size_struct_4 != sizeof (struct_4))
147     abort ();
148 
149   if (size_struct_5 != sizeof (struct_5))
150     abort ();
151 
152   if (size_struct_6 != sizeof (struct_6))
153     abort ();
154 
155   if (size_struct_7 != sizeof (struct_7))
156     abort ();
157 
158   if (size_struct_8 != sizeof (struct_8))
159     abort ();
160 
161   if (size_struct_9 != sizeof (struct_9))
162     abort ();
163 
164   return 0;
165 }
166