2 /* { dg-options "-O2" } */
4 #include "builtin-object-size-common.h"
54 #define T(X, S0, S1) \
55 if (__builtin_object_size (X, 0) != (S0)) \
57 if (__builtin_object_size (X, 1) != (S1)) \
59 if (__builtin_object_size (X, 2) != (S0)) \
61 if (__builtin_object_size (X, 3) != (S1)) \
63 #define TS(X, S0) T(&X, S0, sizeof (X))
64 #define TA(X, S0, S1) \
65 T(X, S0, S1); T(&X[0], S0, S1); T(&X[1], (S0) - 1, (S1) - 1)
66 #define TF(X, S0) TA(X, S0, S0)
75 union A
*a1
= malloc (s
);
76 union A
*a2
= malloc (o
+ 212);
85 a2
= malloc (o
+ 212);
94 union B
*b1
= malloc (s
);
95 union B
*b2
= malloc (o
+ 212);
101 s
= sizeof (union B
);
104 b2
= malloc (o
+ 212);
110 s
= sizeof (union B
);
113 b2
= malloc (o
+ 212);
120 s
= sizeof (struct C
);
121 o
= __builtin_offsetof (struct C
, c2
);
122 struct C
*c1
= malloc (s
);
123 struct C
*c2
= malloc (o
+ 212);
129 s
= sizeof (struct C
);
130 o
= __builtin_offsetof (struct C
, c2
);
132 c2
= malloc (o
+ 212);
133 TS (c1
->c2
.a1
, s
- o
);
135 TS (c2
->c2
.a1
, s
- o
);
138 s
= sizeof (struct C
);
139 o
= __builtin_offsetof (struct C
, c2
);
141 c2
= malloc (o
+ 212);
142 TF (c1
->c2
.a2
, s
- o
);
144 TF (c2
->c2
.a2
, s
- o
);
148 s
= sizeof (struct D
);
149 o
= __builtin_offsetof (struct D
, d2
);
150 struct D
*d1
= malloc (s
);
151 struct D
*d2
= malloc (o
+ 212);
157 s
= sizeof (struct D
);
158 o
= __builtin_offsetof (struct D
, d2
);
160 d2
= malloc (o
+ 212);
161 TS (d1
->d2
.b1
, s
- o
);
163 TS (d2
->d2
.b1
, s
- o
);
166 s
= sizeof (struct D
);
167 o
= __builtin_offsetof (struct D
, d2
);
169 d2
= malloc (o
+ 212);
170 TS (d1
->d2
.b2
.a1
, s
- o
);
172 TS (d2
->d2
.b2
.a1
, s
- o
);
175 s
= sizeof (struct D
);
176 o
= __builtin_offsetof (struct D
, d2
);
178 d2
= malloc (o
+ 212);
179 TF (d1
->d2
.b2
.a2
, s
- o
);
181 TF (d2
->d2
.b2
.a2
, s
- o
);
185 s
= sizeof (union E
);
186 o
= __builtin_offsetof (union E
, e1
.c2
);
187 union E
*e1
= malloc (s
);
188 union E
*e2
= malloc (o
+ 212);
194 s
= sizeof (union E
);
195 o
= __builtin_offsetof (union E
, e1
.c2
);
197 e2
= malloc (o
+ 212);
198 TS (e1
->e1
.c2
.a1
, s
- o
);
200 TS (e2
->e1
.c2
.a1
, s
- o
);
203 s
= sizeof (union E
);
204 o
= __builtin_offsetof (union E
, e1
.c2
);
206 e2
= malloc (o
+ 212);
207 TF (e1
->e1
.c2
.a2
, s
- o
);
209 TF (e2
->e1
.c2
.a2
, s
- o
);
212 s
= sizeof (union E
);
213 o
= __builtin_offsetof (union E
, e1
.c2
);
215 e2
= malloc (o
+ 212);
222 s
= sizeof (union F
);
223 o
= __builtin_offsetof (union F
, f2
.d2
);
224 union F
*f1
= malloc (s
);
225 union F
*f2
= malloc (o
+ 212);
231 s
= sizeof (union F
);
232 o
= __builtin_offsetof (union F
, f2
.d2
);
234 f2
= malloc (o
+ 212);
240 s
= sizeof (union F
);
241 o
= __builtin_offsetof (union F
, f2
.d2
);
243 f2
= malloc (o
+ 212);
244 TS (f1
->f2
.d2
.b1
, s
- o
);
246 TS (f2
->f2
.d2
.b1
, s
- o
);
249 s
= sizeof (union F
);
250 o
= __builtin_offsetof (union F
, f2
.d2
);
252 f2
= malloc (o
+ 212);
253 TS (f1
->f2
.d2
.b2
.a1
, s
- o
);
255 TS (f2
->f2
.d2
.b2
.a1
, s
- o
);
258 s
= sizeof (union F
);
259 o
= __builtin_offsetof (union F
, f2
.d2
);
261 f2
= malloc (o
+ 212);
262 TF (f1
->f2
.d2
.b2
.a2
, s
- o
);
264 TF (f2
->f2
.d2
.b2
.a2
, s
- o
);
268 s
= sizeof (struct G
);
269 o
= __builtin_offsetof (struct G
, g2
);
270 struct G
*g1
= malloc (s
);
271 struct G
*g2
= malloc (o
+ 212);
277 s
= sizeof (struct G
);
278 o
= __builtin_offsetof (struct G
, g2
);
280 g2
= malloc (o
+ 212);
281 TA (g1
->g1
.a2
, s
, sizeof (g1
->g1
.a2
));
283 TA (g2
->g1
.a2
, s
, sizeof (g1
->g1
.a2
));
286 s
= sizeof (struct G
);
287 o
= __builtin_offsetof (struct G
, g2
);
289 g2
= malloc (o
+ 212);
296 s
= sizeof (struct H
);
297 o
= __builtin_offsetof (struct H
, h2
);
298 o2
= __builtin_offsetof (struct H
, h2
.e1
.c2
);
299 struct H
*h1
= malloc (s
);
300 struct H
*h2
= malloc (o2
+ 212);
306 s
= sizeof (struct H
);
307 o
= __builtin_offsetof (struct H
, h2
);
308 o2
= __builtin_offsetof (struct H
, h2
.e1
.c2
);
310 h2
= malloc (o2
+ 212);
311 TS (h1
->h2
.e1
.c1
, s
- o
);
313 TS (h2
->h2
.e1
.c1
, s
- o
);
316 s
= sizeof (struct H
);
317 o
= __builtin_offsetof (struct H
, h2
);
318 o2
= __builtin_offsetof (struct H
, h2
.e1
.c2
);
320 h2
= malloc (o2
+ 212);
321 TS (h1
->h2
.e1
.c2
.a1
, s
- o2
);
323 TS (h2
->h2
.e1
.c2
.a1
, s
- o2
);
326 s
= sizeof (struct H
);
327 o
= __builtin_offsetof (struct H
, h2
);
328 o2
= __builtin_offsetof (struct H
, h2
.e1
.c2
);
330 h2
= malloc (o2
+ 212);
331 TA (h1
->h2
.e1
.c2
.a2
, s
- o2
, sizeof (h1
->h2
.e1
.c2
.a2
));
333 TA (h2
->h2
.e1
.c2
.a2
, s
- o2
, sizeof (h2
->h2
.e1
.c2
.a2
));
336 s
= sizeof (struct H
);
337 o
= __builtin_offsetof (struct H
, h2
);
338 o2
= __builtin_offsetof (struct H
, h2
.e1
.c2
);
340 h2
= malloc (o2
+ 212);
341 TF (h1
->h2
.e2
, s
- o
);
343 TF (h2
->h2
.e2
, s
- o
);