2 // { dg-options "-O2" }
4 typedef __SIZE_TYPE__ size_t;
5 extern "C" void abort ();
6 extern "C" void exit (int);
7 extern "C" void *malloc (size_t);
8 extern "C" void free (void *);
21 __attribute__ ((noinline))
25 if (__builtin_object_size (&p->a, 0) != (size_t) -1)
27 if (__builtin_object_size (&p->a[0], 0) != (size_t) -1)
29 if (__builtin_object_size (&p->a[3], 0) != (size_t) -1)
31 if (__builtin_object_size (&p->b, 0) != (size_t) -1)
33 if (__builtin_object_size (&p->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)
48 if (__builtin_object_size (c, 0) != (size_t) -1)
50 if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
52 if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
54 if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
56 if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
58 if (__builtin_object_size (&p->c, 1) != (size_t) -1)
61 if (__builtin_object_size (c, 1) != sizeof (p->a))
64 if (__builtin_object_size (c, 1) != sizeof (p->a))
67 if (__builtin_object_size (c, 1) != sizeof (p->a) - 3)
70 if (__builtin_object_size (c, 1) != sizeof (p->b))
73 if (__builtin_object_size (c, 1) != (size_t) -1)
75 if (__builtin_object_size (&p->a, 2) != 0)
77 if (__builtin_object_size (&p->a[0], 2) != 0)
79 if (__builtin_object_size (&p->a[3], 2) != 0)
81 if (__builtin_object_size (&p->b, 2) != 0)
83 if (__builtin_object_size (&p->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)
98 if (__builtin_object_size (c, 2) != 0)
100 if (__builtin_object_size (&p->a, 3) != sizeof (p->a))
102 if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a))
104 if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3)
106 if (__builtin_object_size (&p->b, 3) != sizeof (p->b))
108 if (__builtin_object_size (&p->c, 3) != 0)
111 if (__builtin_object_size (c, 3) != sizeof (p->a))
114 if (__builtin_object_size (c, 3) != sizeof (p->a))
117 if (__builtin_object_size (c, 3) != sizeof (p->a) - 3)
120 if (__builtin_object_size (c, 3) != sizeof (p->b))
123 if (__builtin_object_size (c, 3) != 0)
128 __attribute__ ((noinline))
132 size_t s = 2 * sizeof (A);
133 A *p = (A *) malloc (2 * sizeof (A));
134 if (__builtin_object_size (&p->a, 0) != s)
136 if (__builtin_object_size (&p->a[0], 0) != s)
138 if (__builtin_object_size (&p->a[3], 0) != s - 3)
140 if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (A, b))
142 if (__builtin_object_size (&p->c, 0) != s - __builtin_offsetof (A, c))
145 if (__builtin_object_size (c, 0) != s)
148 if (__builtin_object_size (c, 0) != s)
151 if (__builtin_object_size (c, 0) != s - 3)
154 if (__builtin_object_size (c, 0) != s - __builtin_offsetof (A, b))
157 if (__builtin_object_size (c, 0) != s - __builtin_offsetof (A, c))
159 if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
161 if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
163 if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
165 if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
167 if (__builtin_object_size (&p->c, 1) != s - __builtin_offsetof (A, c))
170 if (__builtin_object_size (c, 1) != sizeof (p->a))
173 if (__builtin_object_size (c, 1) != sizeof (p->a))
176 if (__builtin_object_size (c, 1) != sizeof (p->a) - 3)
179 if (__builtin_object_size (c, 1) != sizeof (p->b))
182 if (__builtin_object_size (c, 1) != s - __builtin_offsetof (A, c))
184 if (__builtin_object_size (&p->a, 2) != s)
186 if (__builtin_object_size (&p->a[0], 2) != s)
188 if (__builtin_object_size (&p->a[3], 2) != s - 3)
190 if (__builtin_object_size (&p->b, 2) != s - __builtin_offsetof (A, b))
192 if (__builtin_object_size (&p->c, 2) != s - __builtin_offsetof (A, c))
195 if (__builtin_object_size (c, 2) != s)
198 if (__builtin_object_size (c, 2) != s)
201 if (__builtin_object_size (c, 2) != s - 3)
204 if (__builtin_object_size (c, 2) != s - __builtin_offsetof (A, b))
207 if (__builtin_object_size (c, 2) != s - __builtin_offsetof (A, c))
209 if (__builtin_object_size (&p->a, 3) != sizeof (p->a))
211 if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a))
213 if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3)
215 if (__builtin_object_size (&p->b, 3) != sizeof (p->b))
217 if (__builtin_object_size (&p->c, 3) != s - __builtin_offsetof (A, c))
220 if (__builtin_object_size (c, 3) != sizeof (p->a))
223 if (__builtin_object_size (c, 3) != sizeof (p->a))
226 if (__builtin_object_size (c, 3) != sizeof (p->a) - 3)
229 if (__builtin_object_size (c, 3) != sizeof (p->b))
232 if (__builtin_object_size (c, 3) != s - __builtin_offsetof (A, c))
238 __attribute__ ((noinline))
243 A *p = (A *) malloc (4);
244 if (__builtin_object_size (&p->a, 0) != 4)
246 if (__builtin_object_size (&p->a[0], 0) != 4)
248 if (__builtin_object_size (&p->a[3], 0) != 1)
250 if (__builtin_object_size (&p->b, 0) != 0)
252 if (__builtin_object_size (&p->c, 0) != 0)
254 if (__builtin_object_size (&p->a, 1) != 4)
256 if (__builtin_object_size (&p->a[0], 1) != 4)
258 if (__builtin_object_size (&p->a[3], 1) != 1)
260 if (__builtin_object_size (&p->b, 1) != 0)
262 if (__builtin_object_size (&p->c, 1) != 0)
265 s = __builtin_offsetof (A, c) + 4;
266 p = (A *) malloc (s);
267 if (__builtin_object_size (&p->a, 0) != s)
269 if (__builtin_object_size (&p->a[0], 0) != s)
271 if (__builtin_object_size (&p->a[3], 0) != s - 3)
273 if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (A, b))
275 if (__builtin_object_size (&p->c, 0) != 4)
277 if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
279 if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
281 if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
283 if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
285 if (__builtin_object_size (&p->c, 1) != 4)
296 __attribute__ ((noinline))
297 test4 (struct B *q, int i)
299 if (__builtin_object_size (&q->a[2].a[2], 1) != sizeof (q->a[0].a) - 2)
301 if (__builtin_object_size (&q->a[2].c[2], 1) != sizeof (q->a[0].c) - 2)
303 if (__builtin_object_size (&q->a[3].a[2], 1) != sizeof (q->a[0].a) - 2)
305 if (__builtin_object_size (&q->a[3].c[2], 1) != sizeof (q->a[0].c) - 2)
307 if (__builtin_object_size (&q->a[i].a[2], 1) != sizeof (q->a[0].a) - 2)
309 if (__builtin_object_size (&q->a[i].c[2], 1) != sizeof (q->a[0].c) - 2)
320 __attribute__ ((noinline))
323 if (__builtin_object_size (&c->b, 0) != (size_t) -1)
325 if (__builtin_object_size (&c->b, 1) != 1)
327 if (__builtin_object_size (&c->b, 2) != 0)
329 if (__builtin_object_size (&c->b, 3) != 1)
344 __attribute__ ((noinline))
347 if (__builtin_object_size (&d->j.a[3], 0) != (size_t) -1)
349 if (__builtin_object_size (&d->j.a[3], 1) != sizeof (d->j.a) - 3)
351 if (__builtin_object_size (&d->j.a[3], 2) != 0)
353 if (__builtin_object_size (&d->j.a[3], 3) != sizeof (d->j.a) - 3)
368 __attribute__ ((noinline))
371 if (__builtin_object_size (&e->j[0].a[3], 0) != (size_t) -1)
373 if (__builtin_object_size (&e->j[0].a[3], 1) != sizeof (e->j[0].a) - 3)
375 if (__builtin_object_size (&e->j[0].a[3], 2) != 0)
377 if (__builtin_object_size (&e->j[0].a[3], 3) != sizeof (e->j[0].a) - 3)
379 if (__builtin_object_size ((char *) &e->j[0], 0) != (size_t) -1)
381 if (__builtin_object_size ((char *) &e->j[0], 1) != (size_t) -1)
383 if (__builtin_object_size ((char *) &e->j[0], 2) != 0)
385 if (__builtin_object_size ((char *) &e->j[0], 3) != 0)
400 __attribute__ ((noinline))
403 if (__builtin_object_size (&f->d.c[3], 0) != (size_t) -1)
405 if (__builtin_object_size (&f->d.c[3], 1) != (size_t) -1)
407 if (__builtin_object_size (&f->d.c[3], 2) != 0)
409 if (__builtin_object_size (&f->d.c[3], 3) != 0)
418 __asm ("" : "+r" (p));
423 __asm ("" : "+r" (q), "+r" (i));
425 struct C c, *cp = &c;
426 __asm ("" : "+r" (cp));
428 struct D d, *dp = &d;
429 __asm ("" : "+r" (dp));
431 struct E e, *ep = &e;
432 __asm ("" : "+r" (ep));
435 __asm ("" : "+r" (fp));