@@ -1,8 +1,9 @@
// { dg-do run }
// { dg-options "-O2" }
+#include "../../gcc.dg/builtin-object-size-common.h"
+
typedef __SIZE_TYPE__ size_t;
-extern "C" void abort ();
extern "C" void exit (int);
extern "C" void *malloc (size_t);
extern "C" void free (void *);
@@ -20,105 +21,105 @@ test1 (A *p)
{
char *c;
if (__builtin_object_size (&p->a, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != (size_t) -1)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 2) != 0)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 3) != 0)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 3) != 0)
- abort ();
+ FAIL ();
}
void
@@ -129,105 +130,105 @@ test2 (void)
size_t s = 2 * sizeof (A);
A *p = (A *) malloc (2 * sizeof (A));
if (__builtin_object_size (&p->a, 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != s - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 0) != s)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 0) != s)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 0) != s - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 0) != s - __builtin_offsetof (A, b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 0) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 1) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 2) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 2) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 2) != s - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 2) != s - __builtin_offsetof (A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 2) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 2) != s)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 2) != s)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 2) != s - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 2) != s - __builtin_offsetof (A, b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 2) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 3) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 3) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
free (p);
}
@@ -239,48 +240,48 @@ test3 (void)
size_t s;
A *p = (A *) malloc (4);
if (__builtin_object_size (&p->a, 0) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != 0)
- abort ();
+ FAIL ();
free (p);
s = __builtin_offsetof (A, c) + 4;
p = (A *) malloc (s);
if (__builtin_object_size (&p->a, 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != s - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != 4)
- abort ();
+ FAIL ();
free (p);
}
@@ -294,17 +295,17 @@ __attribute__ ((noinline))
test4 (struct B *q, int i)
{
if (__builtin_object_size (&q->a[2].a[2], 1) != sizeof (q->a[0].a) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[2].c[2], 1) != sizeof (q->a[0].c) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[3].a[2], 1) != sizeof (q->a[0].a) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[3].c[2], 1) != sizeof (q->a[0].c) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[i].a[2], 1) != sizeof (q->a[0].a) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[i].c[2], 1) != sizeof (q->a[0].c) - 2)
- abort ();
+ FAIL ();
}
struct C
@@ -318,13 +319,13 @@ __attribute__ ((noinline))
test5 (struct C *c)
{
if (__builtin_object_size (&c->b, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&c->b, 1) != 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&c->b, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&c->b, 3) != 1)
- abort ();
+ FAIL ();
}
struct D
@@ -342,13 +343,13 @@ __attribute__ ((noinline))
test6 (struct D *d)
{
if (__builtin_object_size (&d->j.a[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&d->j.a[3], 1) != sizeof (d->j.a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&d->j.a[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&d->j.a[3], 3) != sizeof (d->j.a) - 3)
- abort ();
+ FAIL ();
}
struct E
@@ -366,21 +367,21 @@ __attribute__ ((noinline))
test7 (struct E *e)
{
if (__builtin_object_size (&e->j[0].a[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&e->j[0].a[3], 1) != sizeof (e->j[0].a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&e->j[0].a[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&e->j[0].a[3], 3) != sizeof (e->j[0].a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 3) != 0)
- abort ();
+ FAIL ();
}
union F
@@ -398,13 +399,13 @@ __attribute__ ((noinline))
test8 (union F *f)
{
if (__builtin_object_size (&f->d.c[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&f->d.c[3], 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&f->d.c[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&f->d.c[3], 3) != 0)
- abort ();
+ FAIL ();
}
int
@@ -431,5 +432,5 @@ main (void)
union F f, *fp = &f;
__asm ("" : "+r" (fp));
test8 (fp);
- exit (0);
+ DONE ();
}
@@ -1,8 +1,9 @@
// { dg-do run }
// { dg-options "-O2" }
+#include "../../gcc.dg/builtin-object-size-common.h"
+
typedef __SIZE_TYPE__ size_t;
-extern "C" void abort ();
extern "C" void exit (int);
extern "C" void *malloc (size_t);
extern "C" void free (void *);
@@ -23,105 +24,105 @@ test1 (A *p)
{
char *c;
if (__builtin_object_size (&p->a, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != (size_t) -1)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 2) != 0)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 3) != 0)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 3) != 0)
- abort ();
+ FAIL ();
}
void
@@ -132,105 +133,105 @@ test2 (void)
size_t s = 2 * sizeof (A);
A *p = (A *) malloc (2 * sizeof (A));
if (__builtin_object_size (&p->a, 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != s - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 0) != s)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 0) != s)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 0) != s - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 0) != s - __builtin_offsetof (A, b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 0) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 1) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 2) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 2) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 2) != s - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 2) != s - __builtin_offsetof (A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 2) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 2) != s)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 2) != s)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 2) != s - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 2) != s - __builtin_offsetof (A, b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 2) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 3) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 3) != s - __builtin_offsetof (A, c))
- abort ();
+ FAIL ();
free (p);
}
@@ -242,48 +243,48 @@ test3 (void)
size_t s;
A *p = (A *) malloc (4);
if (__builtin_object_size (&p->a, 0) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != 0)
- abort ();
+ FAIL ();
free (p);
s = __builtin_offsetof (A, c) + 4;
p = (A *) malloc (s);
if (__builtin_object_size (&p->a, 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != s - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != 4)
- abort ();
+ FAIL ();
free (p);
}
@@ -297,17 +298,17 @@ __attribute__ ((noinline))
test4 (struct B *q, int i)
{
if (__builtin_object_size (&q->a[2].a[2], 1) != sizeof (q->a[0].a) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[2].c[2], 1) != sizeof (q->a[0].c) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[3].a[2], 1) != sizeof (q->a[0].a) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[3].c[2], 1) != sizeof (q->a[0].c) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[i].a[2], 1) != sizeof (q->a[0].a) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[i].c[2], 1) != sizeof (q->a[0].c) - 2)
- abort ();
+ FAIL ();
}
struct C
@@ -321,13 +322,13 @@ __attribute__ ((noinline))
test5 (struct C *c)
{
if (__builtin_object_size (&c->b, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&c->b, 1) != 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&c->b, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&c->b, 3) != 1)
- abort ();
+ FAIL ();
}
struct D
@@ -345,13 +346,13 @@ __attribute__ ((noinline))
test6 (struct D *d)
{
if (__builtin_object_size (&d->j.a[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&d->j.a[3], 1) != sizeof (d->j.a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&d->j.a[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&d->j.a[3], 3) != sizeof (d->j.a) - 3)
- abort ();
+ FAIL ();
}
struct E
@@ -369,21 +370,21 @@ __attribute__ ((noinline))
test7 (struct E *e)
{
if (__builtin_object_size (&e->j[0].a[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&e->j[0].a[3], 1) != sizeof (e->j[0].a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&e->j[0].a[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&e->j[0].a[3], 3) != sizeof (e->j[0].a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 3) != 0)
- abort ();
+ FAIL ();
}
union F
@@ -401,13 +402,13 @@ __attribute__ ((noinline))
test8 (union F *f)
{
if (__builtin_object_size (&f->d.c[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&f->d.c[3], 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&f->d.c[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&f->d.c[3], 3) != 0)
- abort ();
+ FAIL ();
}
int
@@ -434,5 +435,5 @@ main (void)
union F f, *fp = &f;
__asm ("" : "+r" (fp));
test8 (fp);
- exit (0);
+ DONE ();
}
@@ -1,6 +1,8 @@
/* { dg-do run } */
/* { dg-options "-O2" } */
+#include "builtin-object-size-common.h"
+
typedef __SIZE_TYPE__ size_t;
#define abort __builtin_abort
@@ -539,13 +541,6 @@ test_pr105736 (struct TV4 *a)
return &a->v[0];
}
-unsigned nfails = 0;
-
-#define FAIL() ({ \
- __builtin_printf ("Failure at line: %d\n", __LINE__); \
- nfails++; \
-})
-
int
main (int argc, char **argv)
{
@@ -707,8 +702,5 @@ main (int argc, char **argv)
if (test_strndup_min (str, 4) != 1)
FAIL ();
- if (nfails > 0)
- __builtin_abort ();
-
- return 0;
+ DONE ();
}
@@ -2,8 +2,9 @@
/* { dg-options "-O2 -Wno-stringop-overread" } */
/* { dg-require-effective-target alloca } */
+#include "builtin-object-size-common.h"
+
typedef __SIZE_TYPE__ size_t;
-extern void abort (void);
extern void exit (int);
extern void *malloc (size_t);
extern void *calloc (size_t, size_t);
@@ -39,22 +40,22 @@ test1 (void *q, int x)
r = &a.c[1];
if (__builtin_object_size (p, 0)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&a.c[9], 0)
!= sizeof (a) - __builtin_offsetof (struct A, c) - 9)
- abort ();
+ FAIL ();
if (__builtin_object_size (q, 0) != (size_t) -1)
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (__builtin_object_size (r, 0)
!= (x < 0
? sizeof (a) - __builtin_offsetof (struct A, a) - 9
: sizeof (a) - __builtin_offsetof (struct A, c) - 1))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 0)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 9)
- abort ();
+ FAIL ();
#endif
if (x < 6)
r = &w[2].a[1];
@@ -62,23 +63,23 @@ test1 (void *q, int x)
r = &a.a[6];
if (__builtin_object_size (&y, 0)
!= sizeof (y))
- abort ();
+ FAIL ();
if (__builtin_object_size (w, 0)
!= sizeof (w))
- abort ();
+ FAIL ();
if (__builtin_object_size (&y.b, 0)
!= sizeof (a) - __builtin_offsetof (struct A, b))
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (__builtin_object_size (r, 0)
!= (x < 6
? 2 * sizeof (w[0]) - __builtin_offsetof (struct A, a) - 1
: sizeof (a) - __builtin_offsetof (struct A, a) - 6))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 0)
!= 2 * sizeof (w[0]) - __builtin_offsetof (struct A, a) - 1)
- abort ();
+ FAIL ();
#endif
if (x < 20)
r = malloc (30);
@@ -86,14 +87,14 @@ test1 (void *q, int x)
r = calloc (2, 16);
#ifdef __builtin_object_size
if (__builtin_object_size (r, 0) != (x < 20 ? 30 : 2 * 16))
- abort ();
+ FAIL ();
#else
/* We may duplicate this test onto the two exit paths. On one path
the size will be 32, the other it will be 30. If we don't duplicate
this test, then the size will be 32. */
if (__builtin_object_size (r, 0) != 2 * 16
&& __builtin_object_size (r, 0) != 30)
- abort ();
+ FAIL ();
#endif
if (x < 20)
r = malloc (30);
@@ -101,10 +102,10 @@ test1 (void *q, int x)
r = calloc (2, 14);
#ifdef __builtin_object_size
if (__builtin_object_size (r, 0) != (x < 20 ? 30 : 2 * 14))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 0) != 30)
- abort ();
+ FAIL ();
#endif
if (x < 30)
r = malloc (sizeof (a));
@@ -112,102 +113,102 @@ test1 (void *q, int x)
r = &a.a[3];
#ifdef __builtin_object_size
if (__builtin_object_size (r, 0) != (x < 30 ? sizeof (a) : sizeof (a) - 3))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 0) != sizeof (a))
- abort ();
+ FAIL ();
#endif
r = memcpy (r, "a", 2);
#ifdef __builtin_object_size
if (__builtin_object_size (r, 0) != (x < 30 ? sizeof (a) : sizeof (a) - 3))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 0) != sizeof (a))
- abort ();
+ FAIL ();
#endif
r = memcpy (r + 2, "b", 2) + 2;
#ifdef __builtin_object_size
if (__builtin_object_size (r, 0)
!= (x < 30 ? sizeof (a) - 4 : sizeof (a) - 7))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 0) != sizeof (a) - 4)
- abort ();
+ FAIL ();
#endif
r = &a.a[4];
r = memset (r, 'a', 2);
if (__builtin_object_size (r, 0)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 4)
- abort ();
+ FAIL ();
r = memset (r + 2, 'b', 2) + 2;
if (__builtin_object_size (r, 0)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 8)
- abort ();
+ FAIL ();
r = &a.a[1];
r = strcpy (r, "ab");
if (__builtin_object_size (r, 0)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 1)
- abort ();
+ FAIL ();
r = strcpy (r + 2, "cd") + 2;
if (__builtin_object_size (r, 0)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (exta, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (exta + 10, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&exta[5], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (extb, 0) != sizeof (extb))
- abort ();
+ FAIL ();
if (__builtin_object_size (extb + 10, 0) != sizeof (extb) - 10)
- abort ();
+ FAIL ();
if (__builtin_object_size (&extb[5], 0) != sizeof (extb) - 5)
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (__builtin_object_size (var, 0) != x + 10)
- abort ();
+ FAIL ();
if (__builtin_object_size (var + 10, 0) != x)
- abort ();
+ FAIL ();
if (__builtin_object_size (&var[5], 0) != x + 5)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (var, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (var + 10, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&var[5], 0) != (size_t) -1)
- abort ();
+ FAIL ();
#endif
if (__builtin_object_size (zerol, 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol, 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0], 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (zerol[0].a, 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0].a[0], 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0].b, 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcdefg", 0) != sizeof ("abcdefg"))
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcd\0efg", 0) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg", 0) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg"[0], 0) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg"[4], 0) != sizeof ("abcd\0efg") - 4)
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcd\0efg" + 5, 0) != sizeof ("abcd\0efg") - 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (L"abcdefg", 0) != sizeof (L"abcdefg"))
- abort ();
+ FAIL ();
r = (char *) L"abcd\0efg";
if (__builtin_object_size (r + 2, 0) != sizeof (L"abcd\0efg") - 2)
- abort ();
+ FAIL ();
}
size_t l1 = 1;
@@ -254,7 +255,7 @@ test2 (void)
res = 20;
#endif
if (__builtin_object_size (r, 0) != res)
- abort ();
+ FAIL ();
r = &buf3[20];
for (i = 0; i < 4; ++i)
{
@@ -282,29 +283,29 @@ test2 (void)
res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9;
}
if (__builtin_object_size (r, 0) != res)
- abort ();
+ FAIL ();
#else
res = 15;
#endif
if (__builtin_object_size (r, 0) != res)
- abort ();
+ FAIL ();
r += 8;
#ifdef __builtin_object_size
res -= 8;
if (__builtin_object_size (r, 0) != res)
- abort ();
+ FAIL ();
if (res >= 6)
{
if (__builtin_object_size (r + 6, 0) != res - 6)
- abort ();
+ FAIL ();
}
else if (__builtin_object_size (r + 6, 0) != 0)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 0) != 7)
- abort ();
+ FAIL ();
if (__builtin_object_size (r + 6, 0) != 1)
- abort ();
+ FAIL ();
#endif
r = &buf3[18];
for (i = 0; i < 4; ++i)
@@ -335,13 +336,13 @@ test2 (void)
if (res >= 12)
{
if (__builtin_object_size (r + 12, 0) != res - 12)
- abort ();
+ FAIL ();
}
else if (__builtin_object_size (r + 12, 0) != 0)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r + 12, 0) != 4)
- abort ();
+ FAIL ();
#endif
}
@@ -357,103 +358,103 @@ test3 (void)
double *dp;
if (__builtin_object_size (buf4, 0) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4, 0) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4[0], 0) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4[1], 0) != sizeof (buf4) - 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x, 0) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a, 0) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0], 0) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a, 0) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a[0], 0) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a[3], 0) != sizeof (x) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].b, 0)
!= sizeof (x) - __builtin_offsetof (struct A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c, 0)
!= sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c[0], 0)
!= sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c[3], 0)
!= sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b, 0)
!= sizeof (x) - __builtin_offsetof (struct B, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a, 0)
!= sizeof (x) - __builtin_offsetof (struct B, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a[0], 0)
!= sizeof (x) - __builtin_offsetof (struct B, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a[3], 0)
!= sizeof (x) - __builtin_offsetof (struct B, b) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.b, 0)
!= sizeof (x) - __builtin_offsetof (struct B, b)
- __builtin_offsetof (struct A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c, 0)
!= sizeof (x) - __builtin_offsetof (struct B, b)
- __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c[0], 0)
!= sizeof (x) - __builtin_offsetof (struct B, b)
- __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c[3], 0)
!= sizeof (x) - __builtin_offsetof (struct B, b)
- __builtin_offsetof (struct A, c) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c, 0)
!= sizeof (x) - __builtin_offsetof (struct B, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c[0], 0)
!= sizeof (x) - __builtin_offsetof (struct B, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c[1], 0)
!= sizeof (x) - __builtin_offsetof (struct B, c) - 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.d, 0)
!= sizeof (x) - __builtin_offsetof (struct B, d))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.e, 0)
!= sizeof (x) - __builtin_offsetof (struct B, e))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.f, 0)
!= sizeof (x) - __builtin_offsetof (struct B, f))
- abort ();
+ FAIL ();
dp = &__real__ x.f;
if (__builtin_object_size (dp, 0)
!= sizeof (x) - __builtin_offsetof (struct B, f))
- abort ();
+ FAIL ();
dp = &__imag__ x.f;
if (__builtin_object_size (dp, 0)
!= sizeof (x) - __builtin_offsetof (struct B, f)
- sizeof (x.f) / 2)
- abort ();
+ FAIL ();
dp = &y;
if (__builtin_object_size (dp, 0) != sizeof (y))
- abort ();
+ FAIL ();
if (__builtin_object_size (&z, 0) != sizeof (z))
- abort ();
+ FAIL ();
dp = &__real__ z;
if (__builtin_object_size (dp, 0) != sizeof (z))
- abort ();
+ FAIL ();
dp = &__imag__ z;
if (__builtin_object_size (dp, 0) != sizeof (z) / 2)
- abort ();
+ FAIL ();
}
struct S { unsigned int a; };
@@ -470,7 +471,7 @@ test4 (char *x, int y)
p = (struct A *) x;
x = (char *) &p[1];
if (__builtin_object_size (p, 0) != (size_t) -1)
- abort ();
+ FAIL ();
}
return x;
}
@@ -487,7 +488,7 @@ test5 (size_t x)
p = p + 4;
#ifdef __builtin_object_size
if (__builtin_object_size (p, 0) != sizeof (buf) - 8 - 4 * x)
- abort ();
+ FAIL ();
#else
/* My understanding of ISO C99 6.5.6 is that a conforming
program will not end up with p equal to &buf[0]
@@ -497,7 +498,7 @@ test5 (size_t x)
bytes from p until end of the object is 56, otherwise
it would be 64 (or conservative (size_t) -1 == unknown). */
if (__builtin_object_size (p, 0) != sizeof (buf) - 8)
- abort ();
+ FAIL ();
#endif
memset (p, ' ', sizeof (buf) - 8 - 4 * 4);
}
@@ -514,10 +515,10 @@ test6 (size_t x)
p = p + 4;
#ifdef __builtin_object_size
if (__builtin_object_size (p, 0) != sizeof (t) - 8 - 4 * x)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p, 0) != sizeof (t) - 8)
- abort ();
+ FAIL ();
#endif
memset (p, ' ', sizeof (t) - 8 - 4 * 4);
}
@@ -531,13 +532,13 @@ test7 (void)
char *p = &buf[64], *q = &t.buf[64];
if (__builtin_object_size (p + 64, 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (q + 63, 0) != sizeof (t) - 64 - 63)
- abort ();
+ FAIL ();
if (__builtin_object_size (q + 64, 0) != sizeof (t) - 64 - 64)
- abort ();
+ FAIL ();
if (__builtin_object_size (q + 256, 0) != 0)
- abort ();
+ FAIL ();
}
void
@@ -548,17 +549,17 @@ test8 (void)
char *p = &t.buf2[-4];
char *q = &t.buf2[0];
if (__builtin_object_size (p, 0) != sizeof (t) - 10 + 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (q, 0) != sizeof (t) - 10)
- abort ();
+ FAIL ();
/* GCC only handles additions, not subtractions. */
q = q - 8;
if (__builtin_object_size (q, 0) != (size_t) -1
&& __builtin_object_size (q, 0) != sizeof (t) - 10 + 8)
- abort ();
+ FAIL ();
p = &t.buf[-4];
if (__builtin_object_size (p, 0) != 0)
- abort ();
+ FAIL ();
}
void
@@ -575,10 +576,10 @@ test9 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (&p[-4], 0) != (cond ? 6 : 10))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (&p[-4], 0) != 10)
- abort ();
+ FAIL ();
#endif
for (unsigned i = cond; i > 0; i--)
@@ -586,10 +587,10 @@ test9 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (p, 0) != ((cond ? 2 : 6) + cond))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p, 0) != 10)
- abort ();
+ FAIL ();
#endif
p = &y.c[8];
@@ -599,10 +600,10 @@ test9 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (p, 0)
!= sizeof (y) - __builtin_offsetof (struct A, c) - 8 + cond)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p, 0) != sizeof (y))
- abort ();
+ FAIL ();
#endif
}
@@ -620,10 +621,10 @@ test10 (void)
{
#ifdef __builtin_object_size
if (__builtin_object_size (p - 3, 0) != sizeof (buf) - i + 3)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p - 3, 0) != sizeof (buf))
- abort ();
+ FAIL ();
#endif
break;
}
@@ -641,19 +642,19 @@ test11 (void)
const char *ptr = "abcdefghijklmnopqrstuvwxyz";
char *res = strndup (ptr, 21);
if (__builtin_object_size (res, 0) != 22)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 32);
if (__builtin_object_size (res, 0) != 27)
- abort ();
+ FAIL ();
free (res);
res = strdup (ptr);
if (__builtin_object_size (res, 0) != 27)
- abort ();
+ FAIL ();
free (res);
@@ -662,19 +663,19 @@ test11 (void)
res = strndup (ptr2, 21);
if (__builtin_object_size (res, 0) != 22)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr2, 32);
if (__builtin_object_size (res, 0) != 33)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr2, 128);
if (__builtin_object_size (res, 0) != 64)
- abort ();
+ FAIL ();
free (res);
@@ -684,39 +685,39 @@ test11 (void)
#else
if (__builtin_object_size (res, 0) != (size_t) -1)
#endif
- abort ();
+ FAIL ();
free (res);
free (ptr2);
ptr = "abcd\0efghijklmnopqrstuvwxyz";
res = strdup (ptr);
if (__builtin_object_size (res, 0) != 5)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 24);
if (__builtin_object_size (res, 0) != 5)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 2);
if (__builtin_object_size (res, 0) != 3)
- abort ();
+ FAIL ();
free (res);
res = strdup (&ptr[4]);
if (__builtin_object_size (res, 0) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (&ptr[4], 4);
if (__builtin_object_size (res, 0) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (&ptr[4], 1);
if (__builtin_object_size (res, 0) != 1)
- abort ();
+ FAIL ();
free (res);
}
@@ -736,5 +737,5 @@ main (void)
test9 (1);
test10 ();
test11 ();
- exit (0);
+ DONE ();
}
@@ -1,7 +1,8 @@
/* { dg-do run } */
/* { dg-options "-O2" } */
-extern void abort (void);
+#include "builtin-object-size-common.h"
+
struct S {
int len;
char s[0];
@@ -10,10 +11,11 @@ int main()
{
char buf[sizeof (struct S) + 32];
if (__builtin_object_size (((struct S *)&buf[0])->s, 1) != 32)
- abort ();
+ FAIL ();
if (__builtin_object_size (((struct S *)&buf[1])->s, 1) != 31)
- abort ();
+ FAIL ();
if (__builtin_object_size (((struct S *)&buf[64])->s, 0) != 0)
- abort ();
- return 0;
+ FAIL ();
+
+ DONE ();
}
@@ -1,10 +1,11 @@
/* { dg-do run } */
/* { dg-options "-O2" } */
+#include "builtin-object-size-common.h"
+
typedef __SIZE_TYPE__ size_t;
extern void *malloc (size_t);
extern void free (void *);
-extern void abort (void);
union A
{
@@ -56,13 +57,13 @@ struct H
#define T(X, S0, S1) \
if (__builtin_object_size (X, 0) != (S0)) \
- abort (); \
+ FAIL (); \
if (__builtin_object_size (X, 1) != (S1)) \
- abort (); \
+ FAIL (); \
if (__builtin_object_size (X, 2) != (S0)) \
- abort (); \
+ FAIL (); \
if (__builtin_object_size (X, 3) != (S1)) \
- abort ()
+ FAIL ()
#define TS(X, S0) T(&X, S0, sizeof (X))
#define TA(X, S0, S1) \
T(X, S0, S1); T(&X[0], S0, S1); T(&X[1], (S0) - 1, (S1) - 1)
@@ -347,5 +348,5 @@ main (void)
free (h2);
free (h1);
- return 0;
+ DONE ();
}
@@ -1,7 +1,7 @@
/* { dg-do run } */
/* { dg-options "-O2" } */
-extern void abort (void);
+#include "builtin-object-size-common.h"
int
main ()
@@ -9,12 +9,12 @@ main ()
struct A { char buf1[9]; char buf2[1]; } a;
if (__builtin_object_size (a.buf1 + (0 + 4), 1) != 5)
- abort ();
+ FAIL ();
char *p = a.buf1;
p += 1;
p += 3;
if (__builtin_object_size (p, 1) != 5)
- abort ();
+ FAIL ();
p = (char *) &a;
char *q = p + 1;
char *r = q + 3;
@@ -22,6 +22,7 @@ main ()
if (r != (char *) &a + 4)
t = (char *) &a + 1;
if (__builtin_object_size (t, 1) != 6)
- abort ();
- return 0;
+ FAIL ();
+
+ DONE ();
}
@@ -2,8 +2,9 @@
/* { dg-options "-O2 -Wno-stringop-overread" } */
/* { dg-require-effective-target alloca } */
+#include "builtin-object-size-common.h"
+
typedef __SIZE_TYPE__ size_t;
-extern void abort (void);
extern void exit (int);
extern void *malloc (size_t);
extern void *calloc (size_t, size_t);
@@ -40,39 +41,39 @@ test1 (void *q, int x)
else
r = &a.c[1];
if (__builtin_object_size (p, 1) != sizeof (a.a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&a.c[9], 1)
!= sizeof (a.c) - 9)
- abort ();
+ FAIL ();
if (__builtin_object_size (q, 1) != (size_t) -1)
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (x < 0
? __builtin_object_size (r, 1) != sizeof (a.a) - 9
: __builtin_object_size (r, 1) != sizeof (a.c) - 1)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 1) != sizeof (a.c) - 1)
- abort ();
+ FAIL ();
#endif
if (x < 6)
r = &w[2].a[1];
else
r = &a.a[6];
if (__builtin_object_size (&y, 1) != sizeof (y))
- abort ();
+ FAIL ();
if (__builtin_object_size (w, 1) != sizeof (w))
- abort ();
+ FAIL ();
if (__builtin_object_size (&y.b, 1) != sizeof (a.b))
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (x < 6
? __builtin_object_size (r, 1) != sizeof (a.a) - 1
: __builtin_object_size (r, 1) != sizeof (a.a) - 6)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 1) != sizeof (a.a) - 1)
- abort ();
+ FAIL ();
#endif
if (x < 20)
r = malloc (30);
@@ -80,14 +81,14 @@ test1 (void *q, int x)
r = calloc (2, 16);
#ifdef __builtin_object_size
if (__builtin_object_size (r, 1) != (x < 20 ? 30 : 2 * 16))
- abort ();
+ FAIL ();
#else
/* We may duplicate this test onto the two exit paths. On one path
the size will be 32, the other it will be 30. If we don't duplicate
this test, then the size will be 32. */
if (__builtin_object_size (r, 1) != 2 * 16
&& __builtin_object_size (r, 1) != 30)
- abort ();
+ FAIL ();
#endif
if (x < 20)
r = malloc (30);
@@ -95,10 +96,10 @@ test1 (void *q, int x)
r = calloc (2, 14);
#ifdef __builtin_object_size
if (__builtin_object_size (r, 1) != (x < 20 ? 30 : 2 * 14))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 1) != 30)
- abort ();
+ FAIL ();
#endif
if (x < 30)
r = malloc (sizeof (a));
@@ -106,132 +107,132 @@ test1 (void *q, int x)
r = &a.a[3];
#ifdef __builtin_object_size
if (__builtin_object_size (r, 1) != (x < 30 ? sizeof (a) : sizeof (a) - 3))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 1) != sizeof (a))
- abort ();
+ FAIL ();
#endif
r = memcpy (r, "a", 2);
#ifdef __builtin_object_size
if (__builtin_object_size (r, 1) != (x < 30 ? sizeof (a) : sizeof (a) - 3))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 1) != sizeof (a))
- abort ();
+ FAIL ();
#endif
r = memcpy (r + 2, "b", 2) + 2;
#ifdef __builtin_object_size
if (__builtin_object_size (r, 0)
!= (x < 30 ? sizeof (a) - 4 : sizeof (a) - 7))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 1) != sizeof (a) - 4)
- abort ();
+ FAIL ();
#endif
r = &a.a[4];
r = memset (r, 'a', 2);
if (__builtin_object_size (r, 1) != sizeof (a.a) - 4)
- abort ();
+ FAIL ();
r = memset (r + 2, 'b', 2) + 2;
if (__builtin_object_size (r, 1) != sizeof (a.a) - 8)
- abort ();
+ FAIL ();
r = &a.a[1];
r = strcpy (r, "ab");
if (__builtin_object_size (r, 1) != sizeof (a.a) - 1)
- abort ();
+ FAIL ();
r = strcpy (r + 2, "cd") + 2;
if (__builtin_object_size (r, 1) != sizeof (a.a) - 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (exta, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (exta + 10, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&exta[5], 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (extb, 1) != sizeof (extb))
- abort ();
+ FAIL ();
if (__builtin_object_size (extb + 10, 1) != sizeof (extb) - 10)
- abort ();
+ FAIL ();
if (__builtin_object_size (&extb[5], 1) != sizeof (extb) - 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (extc, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (extc + 10, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&extc[5], 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&extc->a, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&(extc + 10)->b, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&extc[5].c[3], 1) != (size_t) -1)
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (__builtin_object_size (var, 1) != x + 10)
- abort ();
+ FAIL ();
if (__builtin_object_size (var + 10, 1) != x)
- abort ();
+ FAIL ();
if (__builtin_object_size (&var[5], 1) != x + 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (vara, 1) != (x + 10) * sizeof (struct A))
- abort ();
+ FAIL ();
if (__builtin_object_size (vara + 10, 1) != x * sizeof (struct A))
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[5], 1) != (x + 5) * sizeof (struct A))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (var, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (var + 10, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&var[5], 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (vara, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (vara + 10, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[5], 1) != (size_t) -1)
- abort ();
+ FAIL ();
#endif
if (__builtin_object_size (&vara[0].a, 1) != sizeof (vara[0].a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[10].a[0], 1) != sizeof (vara[0].a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[5].a[4], 1) != sizeof (vara[0].a) - 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[5].b, 1) != sizeof (vara[0].b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[7].c[7], 1) != sizeof (vara[0].c) - 7)
- abort ();
+ FAIL ();
if (__builtin_object_size (zerol, 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol, 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0], 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (zerol[0].a, 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0].a[0], 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0].b, 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcdefg", 1) != sizeof ("abcdefg"))
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcd\0efg", 1) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg", 1) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg"[0], 1) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg"[4], 1) != sizeof ("abcd\0efg") - 4)
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcd\0efg" + 5, 1) != sizeof ("abcd\0efg") - 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (L"abcdefg", 1) != sizeof (L"abcdefg"))
- abort ();
+ FAIL ();
r = (char *) L"abcd\0efg";
if (__builtin_object_size (r + 2, 1) != sizeof (L"abcd\0efg") - 2)
- abort ();
+ FAIL ();
}
size_t l1 = 1;
@@ -277,10 +278,10 @@ test2 (void)
dyn_res = sizeof (a.buf1) - 9;
}
if (__builtin_object_size (r, 1) != dyn_res)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 1) != sizeof (buf3))
- abort ();
+ FAIL ();
#endif
r = &buf3[20];
for (i = 0; i < 4; ++i)
@@ -309,10 +310,10 @@ test2 (void)
dyn_res = sizeof (a.buf1) - 9;
}
if (__builtin_object_size (r, 1) != dyn_res)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 1) != sizeof (buf3) - 5)
- abort ();
+ FAIL ();
#endif
r += 8;
#ifdef __builtin_object_size
@@ -320,23 +321,23 @@ test2 (void)
{
dyn_res -= 8;
if (__builtin_object_size (r, 1) != dyn_res)
- abort ();
+ FAIL ();
if (dyn_res >= 6)
{
if (__builtin_object_size (r + 6, 1) != dyn_res - 6)
- abort ();
+ FAIL ();
}
else if (__builtin_object_size (r + 6, 1) != 0)
- abort ();
+ FAIL ();
}
else if (__builtin_object_size (r, 1) != 0)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 1) != sizeof (buf3) - 13)
- abort ();
+ FAIL ();
if (__builtin_object_size (r + 6, 1) != sizeof (buf3) - 19)
- abort ();
+ FAIL ();
#endif
}
@@ -352,78 +353,78 @@ test3 (void)
double *dp;
if (__builtin_object_size (buf4, 1) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4, 1) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4[0], 1) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4[1], 1) != sizeof (buf4) - 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x, 1) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a, 1) != sizeof (x.a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0], 1) != sizeof (x.a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a, 1) != sizeof (x.a[0].a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a[0], 1) != sizeof (x.a[0].a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a[3], 1) != sizeof (x.a[0].a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].b, 1) != sizeof (x.a[0].b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c, 1) != sizeof (x.a[1].c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c[0], 1) != sizeof (x.a[1].c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c[3], 1) != sizeof (x.a[1].c) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b, 1) != sizeof (x.b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a, 1) != sizeof (x.b.a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a[0], 1) != sizeof (x.b.a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a[3], 1) != sizeof (x.b.a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.b, 1) != sizeof (x.b.b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c, 1) != sizeof (x.b.c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c[0], 1) != sizeof (x.b.c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c[3], 1) != sizeof (x.b.c) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c, 1) != sizeof (x.c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c[0], 1) != sizeof (x.c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c[1], 1) != sizeof (x.c) - 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.d, 1) != sizeof (x.d))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.e, 1) != sizeof (x.e))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.f, 1) != sizeof (x.f))
- abort ();
+ FAIL ();
dp = &__real__ x.f;
if (__builtin_object_size (dp, 1) != sizeof (x.f) / 2)
- abort ();
+ FAIL ();
dp = &__imag__ x.f;
if (__builtin_object_size (dp, 1) != sizeof (x.f) / 2)
- abort ();
+ FAIL ();
dp = &y;
if (__builtin_object_size (dp, 1) != sizeof (y))
- abort ();
+ FAIL ();
if (__builtin_object_size (&z, 1) != sizeof (z))
- abort ();
+ FAIL ();
dp = &__real__ z;
if (__builtin_object_size (dp, 1) != sizeof (z) / 2)
- abort ();
+ FAIL ();
dp = &__imag__ z;
if (__builtin_object_size (dp, 1) != sizeof (z) / 2)
- abort ();
+ FAIL ();
}
struct S { unsigned int a; };
@@ -440,7 +441,7 @@ test4 (char *x, int y)
p = (struct A *) x;
x = (char *) &p[1];
if (__builtin_object_size (p, 1) != (size_t) -1)
- abort ();
+ FAIL ();
}
return x;
}
@@ -457,10 +458,10 @@ test5 (size_t x)
p = p + 4;
#ifdef __builtin_object_size
if (__builtin_object_size (p, 1) != sizeof (t.buf) - 8 - 4 * x)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p, 1) != sizeof (t.buf) - 8)
- abort ();
+ FAIL ();
#endif
memset (p, ' ', sizeof (t.buf) - 8 - 4 * 4);
}
@@ -474,11 +475,11 @@ test6 (void)
char *p = &buf[64], *q = &t.buf[64];
if (__builtin_object_size (p + 64, 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (q + 0, 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (q + 64, 1) != 0)
- abort ();
+ FAIL ();
}
void
@@ -489,18 +490,18 @@ test7 (void)
char *p = &t.buf2[-4];
char *q = &t.buf2[0];
if (__builtin_object_size (p, 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (q, 1) != sizeof (t.buf2))
- abort ();
+ FAIL ();
q = &t.buf[10];
if (__builtin_object_size (q, 1) != 0)
- abort ();
+ FAIL ();
q = &t.buf[11];
if (__builtin_object_size (q, 1) != 0)
- abort ();
+ FAIL ();
p = &t.buf[-4];
if (__builtin_object_size (p, 1) != 0)
- abort ();
+ FAIL ();
}
void
@@ -517,10 +518,10 @@ test8 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (&p[-4], 1) != (cond ? 6 : 10))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (&p[-4], 1) != 10)
- abort ();
+ FAIL ();
#endif
for (unsigned i = cond; i > 0; i--)
@@ -528,10 +529,10 @@ test8 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (p, 1) != ((cond ? 2 : 6) + cond))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p, 1) != 10)
- abort ();
+ FAIL ();
#endif
p = &y.c[8];
@@ -540,10 +541,10 @@ test8 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (p, 1) != sizeof (y.c) - 8 + cond)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p, 1) != sizeof (y.c))
- abort ();
+ FAIL ();
#endif
}
@@ -555,19 +556,19 @@ test9 (void)
const char *ptr = "abcdefghijklmnopqrstuvwxyz";
char *res = strndup (ptr, 21);
if (__builtin_object_size (res, 1) != 22)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 32);
if (__builtin_object_size (res, 1) != 27)
- abort ();
+ FAIL ();
free (res);
res = strdup (ptr);
if (__builtin_object_size (res, 1) != 27)
- abort ();
+ FAIL ();
free (res);
@@ -576,19 +577,19 @@ test9 (void)
res = strndup (ptr2, 21);
if (__builtin_object_size (res, 1) != 22)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr2, 32);
if (__builtin_object_size (res, 1) != 33)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr2, 128);
if (__builtin_object_size (res, 1) != 64)
- abort ();
+ FAIL ();
free (res);
@@ -598,7 +599,7 @@ test9 (void)
#else
if (__builtin_object_size (res, 1) != (size_t) -1)
#endif
- abort ();
+ FAIL ();
free (res);
free (ptr2);
@@ -606,32 +607,32 @@ test9 (void)
ptr = "abcd\0efghijklmnopqrstuvwxyz";
res = strdup (ptr);
if (__builtin_object_size (res, 1) != 5)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 24);
if (__builtin_object_size (res, 1) != 5)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 2);
if (__builtin_object_size (res, 1) != 3)
- abort ();
+ FAIL ();
free (res);
res = strdup (&ptr[4]);
if (__builtin_object_size (res, 1) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (&ptr[4], 4);
if (__builtin_object_size (res, 1) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (&ptr[4], 1);
if (__builtin_object_size (res, 1) != 1)
- abort ();
+ FAIL ();
free (res);
}
@@ -649,5 +650,5 @@ main (void)
test7 ();
test8 (1);
test9 ();
- exit (0);
+ DONE ();
}
@@ -2,8 +2,9 @@
/* { dg-options "-O2 -Wno-stringop-overread" } */
/* { dg-require-effective-target alloca } */
+#include "builtin-object-size-common.h"
+
typedef __SIZE_TYPE__ size_t;
-extern void abort (void);
extern void exit (int);
extern void *malloc (size_t);
extern void *calloc (size_t, size_t);
@@ -39,22 +40,22 @@ test1 (void *q, int x)
r = &a.c[1];
if (__builtin_object_size (p, 2)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&a.c[9], 2)
!= sizeof (a) - __builtin_offsetof (struct A, c) - 9)
- abort ();
+ FAIL ();
if (__builtin_object_size (q, 2) != 0)
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (__builtin_object_size (r, 2)
!= (x < 0
? sizeof (a) - __builtin_offsetof (struct A, a) - 9
: sizeof (a) - __builtin_offsetof (struct A, c) - 1))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 2)
!= sizeof (a) - __builtin_offsetof (struct A, c) - 1)
- abort ();
+ FAIL ();
#endif
if (x < 6)
r = &w[2].a[1];
@@ -62,23 +63,23 @@ test1 (void *q, int x)
r = &a.a[6];
if (__builtin_object_size (&y, 2)
!= sizeof (y))
- abort ();
+ FAIL ();
if (__builtin_object_size (w, 2)
!= sizeof (w))
- abort ();
+ FAIL ();
if (__builtin_object_size (&y.b, 2)
!= sizeof (a) - __builtin_offsetof (struct A, b))
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (__builtin_object_size (r, 2)
!= (x < 6
? 2 * sizeof (w[0]) - __builtin_offsetof (struct A, a) - 1
: sizeof (a) - __builtin_offsetof (struct A, a) - 6))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 2)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 6)
- abort ();
+ FAIL ();
#endif
if (x < 20)
r = malloc (30);
@@ -86,10 +87,10 @@ test1 (void *q, int x)
r = calloc (2, 16);
#ifdef __builtin_object_size
if (__builtin_object_size (r, 2) != (x < 20 ? 30 : 2 * 16))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 2) != 30)
- abort ();
+ FAIL ();
#endif
if (x < 20)
r = malloc (30);
@@ -97,10 +98,10 @@ test1 (void *q, int x)
r = calloc (2, 14);
#ifdef __builtin_object_size
if (__builtin_object_size (r, 2) != (x < 20 ? 30 : 2 * 14))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 2) != 2 * 14)
- abort ();
+ FAIL ();
#endif
if (x < 30)
r = malloc (sizeof (a));
@@ -110,104 +111,104 @@ test1 (void *q, int x)
size_t objsz = (x < 30 ? sizeof (a)
: sizeof (a) - __builtin_offsetof (struct A, a) - 3);
if (__builtin_object_size (r, 2) != objsz)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 2)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 3)
- abort ();
+ FAIL ();
#endif
r = memcpy (r, "a", 2);
#ifdef __builtin_object_size
if (__builtin_object_size (r, 2) != objsz)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 2)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 3)
- abort ();
+ FAIL ();
#endif
r = memcpy (r + 2, "b", 2) + 2;
#ifdef __builtin_object_size
if (__builtin_object_size (r, 2) != objsz - 4)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 2)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 3 - 4)
- abort ();
+ FAIL ();
#endif
r = &a.a[4];
r = memset (r, 'a', 2);
if (__builtin_object_size (r, 2)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 4)
- abort ();
+ FAIL ();
r = memset (r + 2, 'b', 2) + 2;
if (__builtin_object_size (r, 2)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 8)
- abort ();
+ FAIL ();
r = &a.a[1];
r = strcpy (r, "ab");
if (__builtin_object_size (r, 2)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 1)
- abort ();
+ FAIL ();
r = strcpy (r + 2, "cd") + 2;
if (__builtin_object_size (r, 2)
!= sizeof (a) - __builtin_offsetof (struct A, a) - 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (exta, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (exta + 10, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&exta[5], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (extb, 2) != sizeof (extb))
- abort ();
+ FAIL ();
if (__builtin_object_size (extb + 10, 2) != sizeof (extb) - 10)
- abort ();
+ FAIL ();
if (__builtin_object_size (&extb[5], 2) != sizeof (extb) - 5)
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (__builtin_object_size (var, 2) != x + 10)
- abort ();
+ FAIL ();
if (__builtin_object_size (var + 10, 2) != x)
- abort ();
+ FAIL ();
if (__builtin_object_size (&var[5], 2) != x + 5)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (var, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (var + 10, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&var[5], 2) != 0)
- abort ();
+ FAIL ();
#endif
if (__builtin_object_size (zerol, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (zerol[0].a, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0].a[0], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0].b, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcdefg", 2) != sizeof ("abcdefg"))
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcd\0efg", 2) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg", 2) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg"[0], 2) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg"[4], 2) != sizeof ("abcd\0efg") - 4)
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcd\0efg" + 5, 2) != sizeof ("abcd\0efg") - 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (L"abcdefg", 2) != sizeof (L"abcdefg"))
- abort ();
+ FAIL ();
r = (char *) L"abcd\0efg";
if (__builtin_object_size (r + 2, 2) != sizeof (L"abcd\0efg") - 2)
- abort ();
+ FAIL ();
}
size_t l1 = 1;
@@ -253,10 +254,10 @@ test2 (void)
dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9;
}
if (__builtin_object_size (r, 2) != dyn_res)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 2) != 3)
- abort ();
+ FAIL ();
#endif
r = &buf3[20];
for (i = 0; i < 4; ++i)
@@ -271,7 +272,7 @@ test2 (void)
r = &a.buf1[9];
}
if (__builtin_object_size (r, 2) != 0)
- abort ();
+ FAIL ();
r = &buf3[2];
for (i = 0; i < 4; ++i)
{
@@ -299,28 +300,28 @@ test2 (void)
dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 4;
}
if (__builtin_object_size (r, 2) != dyn_res)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 2) != 15)
- abort ();
+ FAIL ();
#endif
r += 8;
#ifdef __builtin_object_size
dyn_res -= 8;
if (__builtin_object_size (r, 2) != dyn_res)
- abort ();
+ FAIL ();
if (dyn_res >= 6)
{
if (__builtin_object_size (r + 6, 2) != dyn_res - 6)
- abort ();
+ FAIL ();
}
else if (__builtin_object_size (r + 6, 2) != 0)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 2) != 7)
- abort ();
+ FAIL ();
if (__builtin_object_size (r + 6, 2) != 1)
- abort ();
+ FAIL ();
#endif
r = &buf3[18];
for (i = 0; i < 4; ++i)
@@ -351,13 +352,13 @@ test2 (void)
if (dyn_res >= 12)
{
if (__builtin_object_size (r + 12, 2) != dyn_res - 12)
- abort ();
+ FAIL ();
}
else if (__builtin_object_size (r + 12, 2) != 0)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r + 12, 2) != 0)
- abort ();
+ FAIL ();
#endif
}
@@ -373,103 +374,103 @@ test3 (void)
double *dp;
if (__builtin_object_size (buf4, 2) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4, 2) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4[0], 2) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4[1], 2) != sizeof (buf4) - 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x, 2) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a, 2) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0], 2) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a, 2) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a[0], 2) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a[3], 2) != sizeof (x) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].b, 2)
!= sizeof (x) - __builtin_offsetof (struct A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c, 2)
!= sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c[0], 2)
!= sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c[3], 2)
!= sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b, 2)
!= sizeof (x) - __builtin_offsetof (struct B, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a, 2)
!= sizeof (x) - __builtin_offsetof (struct B, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a[0], 2)
!= sizeof (x) - __builtin_offsetof (struct B, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a[3], 2)
!= sizeof (x) - __builtin_offsetof (struct B, b) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.b, 2)
!= sizeof (x) - __builtin_offsetof (struct B, b)
- __builtin_offsetof (struct A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c, 2)
!= sizeof (x) - __builtin_offsetof (struct B, b)
- __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c[0], 2)
!= sizeof (x) - __builtin_offsetof (struct B, b)
- __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c[3], 2)
!= sizeof (x) - __builtin_offsetof (struct B, b)
- __builtin_offsetof (struct A, c) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c, 2)
!= sizeof (x) - __builtin_offsetof (struct B, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c[0], 2)
!= sizeof (x) - __builtin_offsetof (struct B, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c[1], 2)
!= sizeof (x) - __builtin_offsetof (struct B, c) - 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.d, 2)
!= sizeof (x) - __builtin_offsetof (struct B, d))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.e, 2)
!= sizeof (x) - __builtin_offsetof (struct B, e))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.f, 2)
!= sizeof (x) - __builtin_offsetof (struct B, f))
- abort ();
+ FAIL ();
dp = &__real__ x.f;
if (__builtin_object_size (dp, 2)
!= sizeof (x) - __builtin_offsetof (struct B, f))
- abort ();
+ FAIL ();
dp = &__imag__ x.f;
if (__builtin_object_size (dp, 2)
!= sizeof (x) - __builtin_offsetof (struct B, f)
- sizeof (x.f) / 2)
- abort ();
+ FAIL ();
dp = &y;
if (__builtin_object_size (dp, 2) != sizeof (y))
- abort ();
+ FAIL ();
if (__builtin_object_size (&z, 2) != sizeof (z))
- abort ();
+ FAIL ();
dp = &__real__ z;
if (__builtin_object_size (dp, 2) != sizeof (z))
- abort ();
+ FAIL ();
dp = &__imag__ z;
if (__builtin_object_size (dp, 2) != sizeof (z) / 2)
- abort ();
+ FAIL ();
}
struct S { unsigned int a; };
@@ -486,7 +487,7 @@ test4 (char *x, int y)
p = (struct A *) x;
x = (char *) &p[1];
if (__builtin_object_size (p, 2) != 0)
- abort ();
+ FAIL ();
}
return x;
}
@@ -506,7 +507,7 @@ test5 (size_t x)
#else
if (__builtin_object_size (p, 2) != 0)
#endif
- abort ();
+ FAIL ();
memset (p, ' ', sizeof (buf) - 8 - 4 * 4);
}
@@ -525,7 +526,7 @@ test6 (size_t x)
#else
if (__builtin_object_size (p, 2) != 0)
#endif
- abort ();
+ FAIL ();
memset (p, ' ', sizeof (t) - 8 - 4 * 4);
}
@@ -538,13 +539,13 @@ test7 (void)
char *p = &buf[64], *q = &t.buf[64];
if (__builtin_object_size (p + 64, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (q + 63, 2) != sizeof (t) - 64 - 63)
- abort ();
+ FAIL ();
if (__builtin_object_size (q + 64, 2) != sizeof (t) - 64 - 64)
- abort ();
+ FAIL ();
if (__builtin_object_size (q + 256, 2) != 0)
- abort ();
+ FAIL ();
}
void
@@ -555,17 +556,17 @@ test8 (void)
char *p = &t.buf2[-4];
char *q = &t.buf2[0];
if (__builtin_object_size (p, 2) != sizeof (t) - 10 + 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (q, 2) != sizeof (t) - 10)
- abort ();
+ FAIL ();
/* GCC only handles additions, not subtractions. */
q = q - 8;
if (__builtin_object_size (q, 2) != 0
&& __builtin_object_size (q, 2) != sizeof (t) - 10 + 8)
- abort ();
+ FAIL ();
p = &t.buf[-4];
if (__builtin_object_size (p, 2) != 0)
- abort ();
+ FAIL ();
}
void
@@ -582,10 +583,10 @@ test9 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (&p[-4], 2) != (cond ? 6 : 10))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (&p[-4], 2) != 0)
- abort ();
+ FAIL ();
#endif
for (unsigned i = cond; i > 0; i--)
@@ -593,10 +594,10 @@ test9 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (p, 2) != ((cond ? 2 : 6) + cond))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p, 2) != 0)
- abort ();
+ FAIL ();
#endif
p = &y.c[8];
@@ -606,10 +607,10 @@ test9 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (p, 2)
!= sizeof (y) - __builtin_offsetof (struct A, c) - 8 + cond)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p, 2) != 0)
- abort ();
+ FAIL ();
#endif
}
@@ -627,10 +628,10 @@ test10 (void)
{
#ifdef __builtin_object_size
if (__builtin_object_size (p - 3, 2) != sizeof (buf) - i + 3)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p - 3, 2) != 0)
- abort ();
+ FAIL ();
#endif
break;
}
@@ -647,19 +648,19 @@ test11 (void)
const char *ptr = "abcdefghijklmnopqrstuvwxyz";
char *res = strndup (ptr, 21);
if (__builtin_object_size (res, 2) != 22)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 32);
if (__builtin_object_size (res, 2) != 27)
- abort ();
+ FAIL ();
free (res);
res = strdup (ptr);
if (__builtin_object_size (res, 2) != 27)
- abort ();
+ FAIL ();
free (res);
@@ -668,19 +669,19 @@ test11 (void)
res = strndup (ptr2, 21);
if (__builtin_object_size (res, 2) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr2, 32);
if (__builtin_object_size (res, 2) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr2, 128);
if (__builtin_object_size (res, 2) != 1)
- abort ();
+ FAIL ();
free (res);
@@ -691,7 +692,7 @@ test11 (void)
#else
if (__builtin_object_size (res, 2) != 1)
#endif
- abort ();
+ FAIL ();
free (res);
free (ptr2);
@@ -699,32 +700,32 @@ test11 (void)
ptr = "abcd\0efghijklmnopqrstuvwxyz";
res = strdup (ptr);
if (__builtin_object_size (res, 2) != 5)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 24);
if (__builtin_object_size (res, 2) != 5)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 2);
if (__builtin_object_size (res, 2) != 3)
- abort ();
+ FAIL ();
free (res);
res = strdup (&ptr[4]);
if (__builtin_object_size (res, 2) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (&ptr[4], 4);
if (__builtin_object_size (res, 2) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (&ptr[4], 1);
if (__builtin_object_size (res, 2) != 1)
- abort ();
+ FAIL ();
free (res);
}
@@ -744,5 +745,5 @@ main (void)
test9 (1);
test10 ();
test11 ();
- exit (0);
+ DONE ();
}
@@ -2,8 +2,9 @@
/* { dg-options "-O2 -Wno-stringop-overread" } */
/* { dg-require-effective-target alloca } */
+#include "builtin-object-size-common.h"
+
typedef __SIZE_TYPE__ size_t;
-extern void abort (void);
extern void exit (int);
extern void *malloc (size_t);
extern void *calloc (size_t, size_t);
@@ -40,36 +41,36 @@ test1 (void *q, int x)
else
r = &a.c[1];
if (__builtin_object_size (p, 3) != sizeof (a.a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&a.c[9], 3)
!= sizeof (a.c) - 9)
- abort ();
+ FAIL ();
if (__builtin_object_size (q, 3) != 0)
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (__builtin_object_size (r, 3)
!= (x < 0 ? sizeof (a.a) - 9 : sizeof (a.c) - 1))
#else
if (__builtin_object_size (r, 3) != sizeof (a.a) - 9)
#endif
- abort ();
+ FAIL ();
if (x < 6)
r = &w[2].a[1];
else
r = &a.a[6];
if (__builtin_object_size (&y, 3) != sizeof (y))
- abort ();
+ FAIL ();
if (__builtin_object_size (w, 3) != sizeof (w))
- abort ();
+ FAIL ();
if (__builtin_object_size (&y.b, 3) != sizeof (a.b))
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (__builtin_object_size (r, 3)
!= (x < 6 ? sizeof (w[2].a) - 1 : sizeof (a.a) - 6))
#else
if (__builtin_object_size (r, 3) != sizeof (a.a) - 6)
#endif
- abort ();
+ FAIL ();
if (x < 20)
r = malloc (30);
else
@@ -79,7 +80,7 @@ test1 (void *q, int x)
#else
if (__builtin_object_size (r, 3) != 30)
#endif
- abort ();
+ FAIL ();
if (x < 20)
r = malloc (30);
else
@@ -89,7 +90,7 @@ test1 (void *q, int x)
#else
if (__builtin_object_size (r, 3) != 2 * 14)
#endif
- abort ();
+ FAIL ();
if (x < 30)
r = malloc (sizeof (a));
else
@@ -100,125 +101,125 @@ test1 (void *q, int x)
#else
if (__builtin_object_size (r, 3) != sizeof (a.a) - 3)
#endif
- abort ();
+ FAIL ();
r = memcpy (r, "a", 2);
#ifdef __builtin_object_size
if (__builtin_object_size (r, 3) != objsz)
#else
if (__builtin_object_size (r, 3) != sizeof (a.a) - 3)
#endif
- abort ();
+ FAIL ();
r = memcpy (r + 2, "b", 2) + 2;
#ifdef __builtin_object_size
if (__builtin_object_size (r, 3) != objsz - 4)
#else
if (__builtin_object_size (r, 3) != sizeof (a.a) - 3 - 4)
#endif
- abort ();
+ FAIL ();
r = &a.a[4];
r = memset (r, 'a', 2);
if (__builtin_object_size (r, 3) != sizeof (a.a) - 4)
- abort ();
+ FAIL ();
r = memset (r + 2, 'b', 2) + 2;
if (__builtin_object_size (r, 3) != sizeof (a.a) - 8)
- abort ();
+ FAIL ();
r = &a.a[1];
r = strcpy (r, "ab");
if (__builtin_object_size (r, 3) != sizeof (a.a) - 1)
- abort ();
+ FAIL ();
r = strcpy (r + 2, "cd") + 2;
if (__builtin_object_size (r, 3) != sizeof (a.a) - 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (exta, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (exta + 10, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&exta[5], 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (extb, 3) != sizeof (extb))
- abort ();
+ FAIL ();
if (__builtin_object_size (extb + 10, 3) != sizeof (extb) - 10)
- abort ();
+ FAIL ();
if (__builtin_object_size (&extb[5], 3) != sizeof (extb) - 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (extc, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (extc + 10, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&extc[5], 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&extc->a, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&(extc + 10)->b, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&extc[5].c[3], 3) != 0)
- abort ();
+ FAIL ();
#ifdef __builtin_object_size
if (__builtin_object_size (var, 3) != x + 10)
- abort ();
+ FAIL ();
if (__builtin_object_size (var + 10, 3) != x)
- abort ();
+ FAIL ();
if (__builtin_object_size (&var[5], 3) != x + 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (vara, 3) != (x + 10) * sizeof (struct A))
- abort ();
+ FAIL ();
if (__builtin_object_size (vara + 10, 3) != x * sizeof (struct A))
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[5], 3) != (x + 5) * sizeof (struct A))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (var, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (var + 10, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&var[5], 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (vara, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (vara + 10, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[5], 3) != 0)
- abort ();
+ FAIL ();
#endif
if (__builtin_object_size (&vara[0].a, 3) != sizeof (vara[0].a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[10].a[0], 3) != sizeof (vara[0].a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[5].a[4], 3) != sizeof (vara[0].a) - 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[5].b, 3) != sizeof (vara[0].b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&vara[7].c[7], 3) != sizeof (vara[0].c) - 7)
- abort ();
+ FAIL ();
if (__builtin_object_size (zerol, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0], 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (zerol[0].a, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0].a[0], 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&zerol[0].b, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcdefg", 3) != sizeof ("abcdefg"))
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcd\0efg", 3) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg", 3) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg"[0], 3) != sizeof ("abcd\0efg"))
- abort ();
+ FAIL ();
if (__builtin_object_size (&"abcd\0efg"[4], 3) != sizeof ("abcd\0efg") - 4)
- abort ();
+ FAIL ();
if (__builtin_object_size ("abcd\0efg" + 5, 3) != sizeof ("abcd\0efg") - 5)
- abort ();
+ FAIL ();
if (__builtin_object_size (L"abcdefg", 3) != sizeof (L"abcdefg"))
- abort ();
+ FAIL ();
r = (char *) L"abcd\0efg";
if (__builtin_object_size (r + 2, 3) != sizeof (L"abcd\0efg") - 2)
- abort ();
+ FAIL ();
/* Prevent DSE from removing calls that prevent bad combining of
addresses and offsets. */
asm volatile ("" : : "g" (&a));
@@ -253,7 +254,7 @@ test2 (void)
r = &a.buf1[9];
}
if (__builtin_object_size (r, 3) != sizeof (a.buf1) - 9)
- abort ();
+ FAIL ();
r = &buf3[20];
for (i = 0; i < 4; ++i)
{
@@ -267,7 +268,7 @@ test2 (void)
r = &a.buf1[9];
}
if (__builtin_object_size (r, 3) != 0)
- abort ();
+ FAIL ();
r = &buf3[1];
for (i = 0; i < 4; ++i)
{
@@ -295,22 +296,22 @@ test2 (void)
dyn_res = sizeof (a.buf1) - 2;
}
if (__builtin_object_size (r, 3) != dyn_res)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 3) != sizeof (a.buf1) - 6)
- abort ();
+ FAIL ();
#endif
r += 2;
#ifdef __builtin_object_size
if (__builtin_object_size (r, 3) != dyn_res - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (r + 1, 3) != dyn_res - 3)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (r, 3) != sizeof (a.buf1) - 6 - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (r + 1, 3) != sizeof (a.buf1) - 6 - 3)
- abort ();
+ FAIL ();
#endif
}
@@ -326,78 +327,78 @@ test3 (void)
double *dp;
if (__builtin_object_size (buf4, 3) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4, 3) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4[0], 3) != sizeof (buf4))
- abort ();
+ FAIL ();
if (__builtin_object_size (&buf4[1], 3) != sizeof (buf4) - 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x, 3) != sizeof (x))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a, 3) != sizeof (x.a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0], 3) != sizeof (x.a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a, 3) != sizeof (x.a[0].a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a[0], 3) != sizeof (x.a[0].a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].a[3], 3) != sizeof (x.a[0].a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[0].b, 3) != sizeof (x.a[0].b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c, 3) != sizeof (x.a[1].c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c[0], 3) != sizeof (x.a[1].c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.a[1].c[3], 3) != sizeof (x.a[1].c) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b, 3) != sizeof (x.b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a, 3) != sizeof (x.b.a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a[0], 3) != sizeof (x.b.a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.a[3], 3) != sizeof (x.b.a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.b, 3) != sizeof (x.b.b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c, 3) != sizeof (x.b.c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c[0], 3) != sizeof (x.b.c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.b.c[3], 3) != sizeof (x.b.c) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c, 3) != sizeof (x.c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c[0], 3) != sizeof (x.c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.c[1], 3) != sizeof (x.c) - 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.d, 3) != sizeof (x.d))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.e, 3) != sizeof (x.e))
- abort ();
+ FAIL ();
if (__builtin_object_size (&x.f, 3) != sizeof (x.f))
- abort ();
+ FAIL ();
dp = &__real__ x.f;
if (__builtin_object_size (dp, 3) != sizeof (x.f) / 2)
- abort ();
+ FAIL ();
dp = &__imag__ x.f;
if (__builtin_object_size (dp, 3) != sizeof (x.f) / 2)
- abort ();
+ FAIL ();
dp = &y;
if (__builtin_object_size (dp, 3) != sizeof (y))
- abort ();
+ FAIL ();
if (__builtin_object_size (&z, 3) != sizeof (z))
- abort ();
+ FAIL ();
dp = &__real__ z;
if (__builtin_object_size (dp, 3) != sizeof (z) / 2)
- abort ();
+ FAIL ();
dp = &__imag__ z;
if (__builtin_object_size (dp, 3) != sizeof (z) / 2)
- abort ();
+ FAIL ();
}
struct S { unsigned int a; };
@@ -414,7 +415,7 @@ test4 (char *x, int y)
p = (struct A *) x;
x = (char *) &p[1];
if (__builtin_object_size (p, 3) != 0)
- abort ();
+ FAIL ();
}
return x;
}
@@ -434,7 +435,7 @@ test5 (size_t x)
#else
if (__builtin_object_size (p, 3) != 0)
#endif
- abort ();
+ FAIL ();
memset (p, ' ', sizeof (t.buf) - 8 - 4 * 4);
}
@@ -447,11 +448,11 @@ test6 (void)
char *p = &buf[64], *q = &t.buf[64];
if (__builtin_object_size (p + 64, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (q + 0, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (q + 64, 3) != 0)
- abort ();
+ FAIL ();
}
void
@@ -462,18 +463,18 @@ test7 (void)
char *p = &t.buf2[-4];
char *q = &t.buf2[0];
if (__builtin_object_size (p, 3) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (q, 3) != sizeof (t.buf2))
- abort ();
+ FAIL ();
q = &t.buf[10];
if (__builtin_object_size (q, 3) != 0)
- abort ();
+ FAIL ();
q = &t.buf[11];
if (__builtin_object_size (q, 3) != 0)
- abort ();
+ FAIL ();
p = &t.buf[-4];
if (__builtin_object_size (p, 3) != 0)
- abort ();
+ FAIL ();
}
void
@@ -490,10 +491,10 @@ test8 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (&p[-4], 3) != (cond ? 6 : 10))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (&p[-4], 3) != 0)
- abort ();
+ FAIL ();
#endif
for (unsigned i = cond; i > 0; i--)
@@ -501,10 +502,10 @@ test8 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (p, 3) != ((cond ? 2 : 6) + cond))
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p, 3) != 0)
- abort ();
+ FAIL ();
#endif
p = &y.c[8];
@@ -513,10 +514,10 @@ test8 (unsigned cond)
#ifdef __builtin_object_size
if (__builtin_object_size (p, 3) != sizeof (y.c) - 8 + cond)
- abort ();
+ FAIL ();
#else
if (__builtin_object_size (p, 3) != 0)
- abort ();
+ FAIL ();
#endif
}
@@ -528,19 +529,19 @@ test9 (void)
const char *ptr = "abcdefghijklmnopqrstuvwxyz";
char *res = strndup (ptr, 21);
if (__builtin_object_size (res, 3) != 22)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 32);
if (__builtin_object_size (res, 3) != 27)
- abort ();
+ FAIL ();
free (res);
res = strdup (ptr);
if (__builtin_object_size (res, 3) != 27)
- abort ();
+ FAIL ();
free (res);
@@ -549,19 +550,19 @@ test9 (void)
res = strndup (ptr2, 21);
if (__builtin_object_size (res, 3) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr2, 32);
if (__builtin_object_size (res, 3) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr2, 128);
if (__builtin_object_size (res, 3) != 1)
- abort ();
+ FAIL ();
free (res);
@@ -571,7 +572,7 @@ test9 (void)
#else
if (__builtin_object_size (res, 3) != 1)
#endif
- abort ();
+ FAIL ();
free (res);
free (ptr2);
@@ -579,32 +580,32 @@ test9 (void)
ptr = "abcd\0efghijklmnopqrstuvwxyz";
res = strdup (ptr);
if (__builtin_object_size (res, 3) != 5)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 24);
if (__builtin_object_size (res, 3) != 5)
- abort ();
+ FAIL ();
free (res);
res = strndup (ptr, 2);
if (__builtin_object_size (res, 3) != 3)
- abort ();
+ FAIL ();
free (res);
res = strdup (&ptr[4]);
if (__builtin_object_size (res, 3) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (&ptr[4], 4);
if (__builtin_object_size (res, 3) != 1)
- abort ();
+ FAIL ();
free (res);
res = strndup (&ptr[4], 1);
if (__builtin_object_size (res, 3) != 1)
- abort ();
+ FAIL ();
free (res);
}
@@ -622,5 +623,5 @@ main (void)
test7 ();
test8 (1);
test9 ();
- exit (0);
+ DONE ();
}
@@ -1,8 +1,9 @@
/* { dg-do run } */
/* { dg-options "-O2" } */
+#include "builtin-object-size-common.h"
+
typedef __SIZE_TYPE__ size_t;
-extern void abort (void);
extern void exit (int);
extern void *malloc (size_t);
extern void free (void *);
@@ -20,105 +21,105 @@ test1 (struct A *p)
{
char *c;
if (__builtin_object_size (&p->a, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != (size_t) -1)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 2) != 0)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 3) != 0)
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 3) != 0)
- abort ();
+ FAIL ();
}
void
@@ -129,105 +130,105 @@ test2 (void)
size_t s = 2 * sizeof (struct A);
struct A *p = malloc (2 * sizeof (struct A));
if (__builtin_object_size (&p->a, 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != s - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (struct A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != s - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 0) != s)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 0) != s)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 0) != s - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 0) != s - __builtin_offsetof (struct A, b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 0) != s - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != s - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 1) != s - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 2) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 2) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 2) != s - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 2) != s - __builtin_offsetof (struct A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 2) != s - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 2) != s)
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 2) != s)
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 2) != s - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 2) != s - __builtin_offsetof (struct A, b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 2) != s - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 3) != s - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
c = p->a;
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[0];
if (__builtin_object_size (c, 3) != sizeof (p->a))
- abort ();
+ FAIL ();
c = &p->a[3];
if (__builtin_object_size (c, 3) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
c = (char *) &p->b;
if (__builtin_object_size (c, 3) != sizeof (p->b))
- abort ();
+ FAIL ();
c = (char *) &p->c;
if (__builtin_object_size (c, 3) != s - __builtin_offsetof (struct A, c))
- abort ();
+ FAIL ();
free (p);
}
@@ -239,48 +240,48 @@ test3 (void)
size_t s;
struct A *p = malloc (4);
if (__builtin_object_size (&p->a, 0) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != 0)
- abort ();
+ FAIL ();
free (p);
s = __builtin_offsetof (struct A, c) + 4;
p = malloc (s);
if (__builtin_object_size (&p->a, 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 0) != s)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 0) != s - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (struct A, b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 0) != 4)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
- abort ();
+ FAIL ();
if (__builtin_object_size (&p->c, 1) != 4)
- abort ();
+ FAIL ();
free (p);
}
@@ -294,17 +295,17 @@ __attribute__ ((noinline))
test4 (struct B *q, int i)
{
if (__builtin_object_size (&q->a[2].a[2], 1) != sizeof (q->a[0].a) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[2].c[2], 1) != sizeof (q->a[0].c) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[3].a[2], 1) != sizeof (q->a[0].a) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[3].c[2], 1) != sizeof (q->a[0].c) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[i].a[2], 1) != sizeof (q->a[0].a) - 2)
- abort ();
+ FAIL ();
if (__builtin_object_size (&q->a[i].c[2], 1) != sizeof (q->a[0].c) - 2)
- abort ();
+ FAIL ();
}
struct C
@@ -318,13 +319,13 @@ __attribute__ ((noinline))
test5 (struct C *c)
{
if (__builtin_object_size (&c->b, 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&c->b, 1) != 1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&c->b, 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&c->b, 3) != 1)
- abort ();
+ FAIL ();
}
struct D
@@ -342,13 +343,13 @@ __attribute__ ((noinline))
test6 (struct D *d)
{
if (__builtin_object_size (&d->j.a[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&d->j.a[3], 1) != sizeof (d->j.a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&d->j.a[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&d->j.a[3], 3) != sizeof (d->j.a) - 3)
- abort ();
+ FAIL ();
}
struct E
@@ -366,21 +367,21 @@ __attribute__ ((noinline))
test7 (struct E *e)
{
if (__builtin_object_size (&e->j[0].a[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&e->j[0].a[3], 1) != sizeof (e->j[0].a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size (&e->j[0].a[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&e->j[0].a[3], 3) != sizeof (e->j[0].a) - 3)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size ((char *) &e->j[0], 3) != 0)
- abort ();
+ FAIL ();
}
union F
@@ -398,13 +399,13 @@ __attribute__ ((noinline))
test8 (union F *f)
{
if (__builtin_object_size (&f->d.c[3], 0) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&f->d.c[3], 1) != (size_t) -1)
- abort ();
+ FAIL ();
if (__builtin_object_size (&f->d.c[3], 2) != 0)
- abort ();
+ FAIL ();
if (__builtin_object_size (&f->d.c[3], 3) != 0)
- abort ();
+ FAIL ();
}
int
@@ -431,5 +432,5 @@ main (void)
union F f, *fp = &f;
__asm ("" : "+r" (fp));
test8 (fp);
- exit (0);
+ DONE ();
}
@@ -1,6 +1,8 @@
/* { dg-do run } */
/* { dg-options "-O2" } */
+#include "builtin-object-size-common.h"
+
typedef __SIZE_TYPE__ size_t;
extern void *malloc (size_t);
extern void abort (void);
@@ -20,52 +22,52 @@ main (void)
struct A *a = malloc (s);
struct A *b = malloc (o + 212);
if (__builtin_object_size (a->buf, 0) != s - o)
- abort ();
+ FAIL ();
if (__builtin_object_size (a->buf, 1) != sizeof (a->buf))
- abort ();
+ FAIL ();
if (__builtin_object_size (a->buf, 2) != s - o)
- abort ();
+ FAIL ();
if (__builtin_object_size (a->buf, 3) != sizeof (a->buf))
- abort ();
+ FAIL ();
if (__builtin_object_size (&a->buf[0], 0) != s - o)
- abort ();
+ FAIL ();
if (__builtin_object_size (&a->buf[0], 1) != sizeof (a->buf))
- abort ();
+ FAIL ();
if (__builtin_object_size (&a->buf[0], 2) != s - o)
- abort ();
+ FAIL ();
if (__builtin_object_size (&a->buf[0], 3) != sizeof (a->buf))
- abort ();
+ FAIL ();
if (__builtin_object_size (&a->buf[6], 0) != s - o - 6)
- abort ();
+ FAIL ();
if (__builtin_object_size (&a->buf[6], 1) != sizeof (a->buf) - 6)
- abort ();
+ FAIL ();
if (__builtin_object_size (&a->buf[6], 2) != s - o - 6)
- abort ();
+ FAIL ();
if (__builtin_object_size (&a->buf[6], 3) != sizeof (a->buf) - 6)
- abort ();
+ FAIL ();
if (__builtin_object_size (b->buf, 0) != 212)
- abort ();
+ FAIL ();
if (__builtin_object_size (b->buf, 1) != 212)
- abort ();
+ FAIL ();
if (__builtin_object_size (b->buf, 2) != 212)
- abort ();
+ FAIL ();
if (__builtin_object_size (b->buf, 3) != 212)
- abort ();
+ FAIL ();
if (__builtin_object_size (&b->buf[0], 0) != 212)
- abort ();
+ FAIL ();
if (__builtin_object_size (&b->buf[0], 1) != 212)
- abort ();
+ FAIL ();
if (__builtin_object_size (&b->buf[0], 2) != 212)
- abort ();
+ FAIL ();
if (__builtin_object_size (&b->buf[0], 3) != 212)
- abort ();
+ FAIL ();
if (__builtin_object_size (&b->buf[28], 0) != 212 - 28)
- abort ();
+ FAIL ();
if (__builtin_object_size (&b->buf[28], 1) != 212 - 28)
- abort ();
+ FAIL ();
if (__builtin_object_size (&b->buf[28], 2) != 212 - 28)
- abort ();
+ FAIL ();
if (__builtin_object_size (&b->buf[28], 3) != 212 - 28)
- abort ();
- return 0;
+ FAIL ();
+ DONE ();
}
@@ -1,10 +1,11 @@
/* { dg-do run } */
/* { dg-options "-O2" } */
+#include "builtin-object-size-common.h"
+
typedef __SIZE_TYPE__ size_t;
extern void *malloc (size_t);
extern void free (void *);
-extern void abort (void);
union A
{
@@ -56,13 +57,13 @@ struct H
#define T(X, S0, S1) \
if (__builtin_object_size (X, 0) != (S0)) \
- abort (); \
+ FAIL (); \
if (__builtin_object_size (X, 1) != (S1)) \
- abort (); \
+ FAIL (); \
if (__builtin_object_size (X, 2) != (S0)) \
- abort (); \
+ FAIL (); \
if (__builtin_object_size (X, 3) != (S1)) \
- abort ()
+ FAIL ()
#define TS(X, S0) T(&X, S0, sizeof (X))
#define TA(X, S0, S1) \
T(X, S0, S1); T(&X[0], S0, S1); T(&X[1], (S0) - 1, (S1) - 1)
@@ -196,5 +197,5 @@ main (void)
free (h2);
free (h1);
- return 0;
+ DONE ();
}
new file mode 100644
@@ -0,0 +1,12 @@
+unsigned nfails = 0;
+
+#define FAIL() ({ \
+ __builtin_printf ("Failure at line: %d\n", __LINE__); \
+ nfails++; \
+})
+
+#define DONE() ({ \
+ if (nfails > 0) \
+ __builtin_abort (); \
+ return 0; \
+})
@@ -4,16 +4,17 @@
/* { dg-do run } */
/* { dg-options "-O2 -fstrict-flex-arrays" } */
-#include <stdio.h>
+#include "builtin-object-size-common.h"
+typedef __SIZE_TYPE__ size_t;
#define expect(p, _v) do { \
size_t v = _v; \
if (p == v) \
- printf("ok: %s == %zd\n", #p, p); \
+ __builtin_printf("ok: %s == %zd\n", #p, p); \
else \
{ \
- printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
- __builtin_abort (); \
+ __builtin_printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
+ FAIL (); \
} \
} while (0);
@@ -56,5 +57,5 @@ int main(int argc, char *argv[])
{
stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]);
- return 0;
+ DONE ();
}
@@ -4,16 +4,17 @@
/* { dg-do run } */
/* { dg-options "-O2 -fstrict-flex-arrays=0" } */
-#include <stdio.h>
+#include "builtin-object-size-common.h"
+typedef __SIZE_TYPE__ size_t;
#define expect(p, _v) do { \
size_t v = _v; \
if (p == v) \
- printf("ok: %s == %zd\n", #p, p); \
+ __builtin_printf ("ok: %s == %zd\n", #p, p); \
else \
{ \
- printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
- __builtin_abort (); \
+ __builtin_printf ("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
+ FAIL (); \
} \
} while (0);
@@ -56,5 +57,5 @@ int main(int argc, char *argv[])
{
stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]);
- return 0;
+ DONE ();
}