2 /* { dg-options "-O2" } */
4 typedef __SIZE_TYPE__
size_t;
5 extern void abort (void);
6 extern void exit (int);
7 extern void *malloc (size_t);
8 extern void free (void *);
18 __attribute__ ((noinline
))
22 if (__builtin_object_size (&p
->a
, 0) != (size_t) -1)
24 if (__builtin_object_size (&p
->a
[0], 0) != (size_t) -1)
26 if (__builtin_object_size (&p
->a
[3], 0) != (size_t) -1)
28 if (__builtin_object_size (&p
->b
, 0) != (size_t) -1)
30 if (__builtin_object_size (&p
->c
, 0) != (size_t) -1)
33 if (__builtin_object_size (c
, 0) != (size_t) -1)
36 if (__builtin_object_size (c
, 0) != (size_t) -1)
39 if (__builtin_object_size (c
, 0) != (size_t) -1)
42 if (__builtin_object_size (c
, 0) != (size_t) -1)
45 if (__builtin_object_size (c
, 0) != (size_t) -1)
47 if (__builtin_object_size (&p
->a
, 1) != sizeof (p
->a
))
49 if (__builtin_object_size (&p
->a
[0], 1) != sizeof (p
->a
))
51 if (__builtin_object_size (&p
->a
[3], 1) != sizeof (p
->a
) - 3)
53 if (__builtin_object_size (&p
->b
, 1) != sizeof (p
->b
))
55 if (__builtin_object_size (&p
->c
, 1) != (size_t) -1)
58 if (__builtin_object_size (c
, 1) != sizeof (p
->a
))
61 if (__builtin_object_size (c
, 1) != sizeof (p
->a
))
64 if (__builtin_object_size (c
, 1) != sizeof (p
->a
) - 3)
67 if (__builtin_object_size (c
, 1) != sizeof (p
->b
))
70 if (__builtin_object_size (c
, 1) != (size_t) -1)
72 if (__builtin_object_size (&p
->a
, 2) != 0)
74 if (__builtin_object_size (&p
->a
[0], 2) != 0)
76 if (__builtin_object_size (&p
->a
[3], 2) != 0)
78 if (__builtin_object_size (&p
->b
, 2) != 0)
80 if (__builtin_object_size (&p
->c
, 2) != 0)
83 if (__builtin_object_size (c
, 2) != 0)
86 if (__builtin_object_size (c
, 2) != 0)
89 if (__builtin_object_size (c
, 2) != 0)
92 if (__builtin_object_size (c
, 2) != 0)
95 if (__builtin_object_size (c
, 2) != 0)
97 if (__builtin_object_size (&p
->a
, 3) != sizeof (p
->a
))
99 if (__builtin_object_size (&p
->a
[0], 3) != sizeof (p
->a
))
101 if (__builtin_object_size (&p
->a
[3], 3) != sizeof (p
->a
) - 3)
103 if (__builtin_object_size (&p
->b
, 3) != sizeof (p
->b
))
105 if (__builtin_object_size (&p
->c
, 3) != 0)
108 if (__builtin_object_size (c
, 3) != sizeof (p
->a
))
111 if (__builtin_object_size (c
, 3) != sizeof (p
->a
))
114 if (__builtin_object_size (c
, 3) != sizeof (p
->a
) - 3)
117 if (__builtin_object_size (c
, 3) != sizeof (p
->b
))
120 if (__builtin_object_size (c
, 3) != 0)
125 __attribute__ ((noinline
))
129 size_t s
= 2 * sizeof (struct A
);
130 struct A
*p
= malloc (2 * sizeof (struct A
));
131 if (__builtin_object_size (&p
->a
, 0) != s
)
133 if (__builtin_object_size (&p
->a
[0], 0) != s
)
135 if (__builtin_object_size (&p
->a
[3], 0) != s
- 3)
137 if (__builtin_object_size (&p
->b
, 0) != s
- __builtin_offsetof (struct A
, b
))
139 if (__builtin_object_size (&p
->c
, 0) != s
- __builtin_offsetof (struct A
, c
))
142 if (__builtin_object_size (c
, 0) != s
)
145 if (__builtin_object_size (c
, 0) != s
)
148 if (__builtin_object_size (c
, 0) != s
- 3)
151 if (__builtin_object_size (c
, 0) != s
- __builtin_offsetof (struct A
, b
))
154 if (__builtin_object_size (c
, 0) != s
- __builtin_offsetof (struct A
, c
))
156 if (__builtin_object_size (&p
->a
, 1) != sizeof (p
->a
))
158 if (__builtin_object_size (&p
->a
[0], 1) != sizeof (p
->a
))
160 if (__builtin_object_size (&p
->a
[3], 1) != sizeof (p
->a
) - 3)
162 if (__builtin_object_size (&p
->b
, 1) != sizeof (p
->b
))
164 if (__builtin_object_size (&p
->c
, 1) != s
- __builtin_offsetof (struct A
, c
))
167 if (__builtin_object_size (c
, 1) != sizeof (p
->a
))
170 if (__builtin_object_size (c
, 1) != sizeof (p
->a
))
173 if (__builtin_object_size (c
, 1) != sizeof (p
->a
) - 3)
176 if (__builtin_object_size (c
, 1) != sizeof (p
->b
))
179 if (__builtin_object_size (c
, 1) != s
- __builtin_offsetof (struct A
, c
))
181 if (__builtin_object_size (&p
->a
, 2) != s
)
183 if (__builtin_object_size (&p
->a
[0], 2) != s
)
185 if (__builtin_object_size (&p
->a
[3], 2) != s
- 3)
187 if (__builtin_object_size (&p
->b
, 2) != s
- __builtin_offsetof (struct A
, b
))
189 if (__builtin_object_size (&p
->c
, 2) != s
- __builtin_offsetof (struct A
, c
))
192 if (__builtin_object_size (c
, 2) != s
)
195 if (__builtin_object_size (c
, 2) != s
)
198 if (__builtin_object_size (c
, 2) != s
- 3)
201 if (__builtin_object_size (c
, 2) != s
- __builtin_offsetof (struct A
, b
))
204 if (__builtin_object_size (c
, 2) != s
- __builtin_offsetof (struct A
, c
))
206 if (__builtin_object_size (&p
->a
, 3) != sizeof (p
->a
))
208 if (__builtin_object_size (&p
->a
[0], 3) != sizeof (p
->a
))
210 if (__builtin_object_size (&p
->a
[3], 3) != sizeof (p
->a
) - 3)
212 if (__builtin_object_size (&p
->b
, 3) != sizeof (p
->b
))
214 if (__builtin_object_size (&p
->c
, 3) != s
- __builtin_offsetof (struct A
, c
))
217 if (__builtin_object_size (c
, 3) != sizeof (p
->a
))
220 if (__builtin_object_size (c
, 3) != sizeof (p
->a
))
223 if (__builtin_object_size (c
, 3) != sizeof (p
->a
) - 3)
226 if (__builtin_object_size (c
, 3) != sizeof (p
->b
))
229 if (__builtin_object_size (c
, 3) != s
- __builtin_offsetof (struct A
, c
))
235 __attribute__ ((noinline
))
240 struct A
*p
= malloc (4);
241 if (__builtin_object_size (&p
->a
, 0) != 4)
243 if (__builtin_object_size (&p
->a
[0], 0) != 4)
245 if (__builtin_object_size (&p
->a
[3], 0) != 1)
247 if (__builtin_object_size (&p
->b
, 0) != 0)
249 if (__builtin_object_size (&p
->c
, 0) != 0)
251 if (__builtin_object_size (&p
->a
, 1) != 4)
253 if (__builtin_object_size (&p
->a
[0], 1) != 4)
255 if (__builtin_object_size (&p
->a
[3], 1) != 1)
257 if (__builtin_object_size (&p
->b
, 1) != 0)
259 if (__builtin_object_size (&p
->c
, 1) != 0)
262 s
= __builtin_offsetof (struct A
, c
) + 4;
264 if (__builtin_object_size (&p
->a
, 0) != s
)
266 if (__builtin_object_size (&p
->a
[0], 0) != s
)
268 if (__builtin_object_size (&p
->a
[3], 0) != s
- 3)
270 if (__builtin_object_size (&p
->b
, 0) != s
- __builtin_offsetof (struct A
, b
))
272 if (__builtin_object_size (&p
->c
, 0) != 4)
274 if (__builtin_object_size (&p
->a
, 1) != sizeof (p
->a
))
276 if (__builtin_object_size (&p
->a
[0], 1) != sizeof (p
->a
))
278 if (__builtin_object_size (&p
->a
[3], 1) != sizeof (p
->a
) - 3)
280 if (__builtin_object_size (&p
->b
, 1) != sizeof (p
->b
))
282 if (__builtin_object_size (&p
->c
, 1) != 4)
293 __attribute__ ((noinline
))
294 test4 (struct B
*q
, int i
)
296 if (__builtin_object_size (&q
->a
[2].a
[2], 1) != sizeof (q
->a
[0].a
) - 2)
298 if (__builtin_object_size (&q
->a
[2].c
[2], 1) != sizeof (q
->a
[0].c
) - 2)
300 if (__builtin_object_size (&q
->a
[3].a
[2], 1) != sizeof (q
->a
[0].a
) - 2)
302 if (__builtin_object_size (&q
->a
[3].c
[2], 1) != sizeof (q
->a
[0].c
) - 2)
304 if (__builtin_object_size (&q
->a
[i
].a
[2], 1) != sizeof (q
->a
[0].a
) - 2)
306 if (__builtin_object_size (&q
->a
[i
].c
[2], 1) != sizeof (q
->a
[0].c
) - 2)
317 __attribute__ ((noinline
))
320 if (__builtin_object_size (&c
->b
, 0) != (size_t) -1)
322 if (__builtin_object_size (&c
->b
, 1) != 1)
324 if (__builtin_object_size (&c
->b
, 2) != 0)
326 if (__builtin_object_size (&c
->b
, 3) != 1)
341 __attribute__ ((noinline
))
344 if (__builtin_object_size (&d
->j
.a
[3], 0) != (size_t) -1)
346 if (__builtin_object_size (&d
->j
.a
[3], 1) != sizeof (d
->j
.a
) - 3)
348 if (__builtin_object_size (&d
->j
.a
[3], 2) != 0)
350 if (__builtin_object_size (&d
->j
.a
[3], 3) != sizeof (d
->j
.a
) - 3)
365 __attribute__ ((noinline
))
368 if (__builtin_object_size (&e
->j
[0].a
[3], 0) != (size_t) -1)
370 if (__builtin_object_size (&e
->j
[0].a
[3], 1) != sizeof (e
->j
[0].a
) - 3)
372 if (__builtin_object_size (&e
->j
[0].a
[3], 2) != 0)
374 if (__builtin_object_size (&e
->j
[0].a
[3], 3) != sizeof (e
->j
[0].a
) - 3)
376 if (__builtin_object_size ((char *) &e
->j
[0], 0) != (size_t) -1)
378 if (__builtin_object_size ((char *) &e
->j
[0], 1) != (size_t) -1)
380 if (__builtin_object_size ((char *) &e
->j
[0], 2) != 0)
382 if (__builtin_object_size ((char *) &e
->j
[0], 3) != 0)
397 __attribute__ ((noinline
))
400 if (__builtin_object_size (&f
->d
.c
[3], 0) != (size_t) -1)
402 if (__builtin_object_size (&f
->d
.c
[3], 1) != (size_t) -1)
404 if (__builtin_object_size (&f
->d
.c
[3], 2) != 0)
406 if (__builtin_object_size (&f
->d
.c
[3], 3) != 0)
415 __asm ("" : "+r" (p
));
420 __asm ("" : "+r" (q
), "+r" (i
));
422 struct C c
, *cp
= &c
;
423 __asm ("" : "+r" (cp
));
425 struct D d
, *dp
= &d
;
426 __asm ("" : "+r" (dp
));
428 struct E e
, *ep
= &e
;
429 __asm ("" : "+r" (ep
));
432 __asm ("" : "+r" (fp
));