mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-04 22:41:34 +08:00
tree-object-size.c (addr_object_size): Fix a pasto in the last change.
* tree-object-size.c (addr_object_size): Fix a pasto in the last change. * gcc.dg/builtin-object-size-7.c: New test. From-SVN: r148503
This commit is contained in:
parent
081b044b49
commit
98a129b9c4
@ -1,3 +1,8 @@
|
||||
2009-06-15 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* tree-object-size.c (addr_object_size): Fix a pasto in the last
|
||||
change.
|
||||
|
||||
2009-06-15 Rafael Avila de Espindola <espindola@google.com>
|
||||
|
||||
* cgraph.c (cgraph_make_node_local): Use DECL_COMDAT_GROUP.
|
||||
|
@ -1,3 +1,7 @@
|
||||
2009-06-15 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* gcc.dg/builtin-object-size-7.c: New test.
|
||||
|
||||
2009-06-15 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR testsuite/40426
|
||||
|
71
gcc/testsuite/gcc.dg/builtin-object-size-7.c
Normal file
71
gcc/testsuite/gcc.dg/builtin-object-size-7.c
Normal file
@ -0,0 +1,71 @@
|
||||
/* { dg-do run } */
|
||||
/* { dg-options "-O2" } */
|
||||
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
extern void *malloc (size_t);
|
||||
extern void abort (void);
|
||||
|
||||
struct A
|
||||
{
|
||||
int i, j, k;
|
||||
char buf[255];
|
||||
int l, m, n, o;
|
||||
};
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
const size_t s = sizeof (struct A);
|
||||
const size_t o = __builtin_offsetof (struct A, buf);
|
||||
struct A *a = malloc (s);
|
||||
struct A *b = malloc (o + 212);
|
||||
if (__builtin_object_size (a->buf, 0) != s - o)
|
||||
abort ();
|
||||
if (__builtin_object_size (a->buf, 1) != sizeof (a->buf))
|
||||
abort ();
|
||||
if (__builtin_object_size (a->buf, 2) != s - o)
|
||||
abort ();
|
||||
if (__builtin_object_size (a->buf, 3) != sizeof (a->buf))
|
||||
abort ();
|
||||
if (__builtin_object_size (&a->buf[0], 0) != s - o)
|
||||
abort ();
|
||||
if (__builtin_object_size (&a->buf[0], 1) != sizeof (a->buf))
|
||||
abort ();
|
||||
if (__builtin_object_size (&a->buf[0], 2) != s - o)
|
||||
abort ();
|
||||
if (__builtin_object_size (&a->buf[0], 3) != sizeof (a->buf))
|
||||
abort ();
|
||||
if (__builtin_object_size (&a->buf[6], 0) != s - o - 6)
|
||||
abort ();
|
||||
if (__builtin_object_size (&a->buf[6], 1) != sizeof (a->buf) - 6)
|
||||
abort ();
|
||||
if (__builtin_object_size (&a->buf[6], 2) != s - o - 6)
|
||||
abort ();
|
||||
if (__builtin_object_size (&a->buf[6], 3) != sizeof (a->buf) - 6)
|
||||
abort ();
|
||||
if (__builtin_object_size (b->buf, 0) != 212)
|
||||
abort ();
|
||||
if (__builtin_object_size (b->buf, 1) != 212)
|
||||
abort ();
|
||||
if (__builtin_object_size (b->buf, 2) != 212)
|
||||
abort ();
|
||||
if (__builtin_object_size (b->buf, 3) != 212)
|
||||
abort ();
|
||||
if (__builtin_object_size (&b->buf[0], 0) != 212)
|
||||
abort ();
|
||||
if (__builtin_object_size (&b->buf[0], 1) != 212)
|
||||
abort ();
|
||||
if (__builtin_object_size (&b->buf[0], 2) != 212)
|
||||
abort ();
|
||||
if (__builtin_object_size (&b->buf[0], 3) != 212)
|
||||
abort ();
|
||||
if (__builtin_object_size (&b->buf[28], 0) != 212 - 28)
|
||||
abort ();
|
||||
if (__builtin_object_size (&b->buf[28], 1) != 212 - 28)
|
||||
abort ();
|
||||
if (__builtin_object_size (&b->buf[28], 2) != 212 - 28)
|
||||
abort ();
|
||||
if (__builtin_object_size (&b->buf[28], 3) != 212 - 28)
|
||||
abort ();
|
||||
return 0;
|
||||
}
|
@ -317,7 +317,7 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
|
||||
&& tree_int_cst_lt (pt_var_size, bytes2))
|
||||
bytes2 = size_zero_node;
|
||||
else
|
||||
bytes2 = size_binop (MINUS_EXPR, var_size, bytes2);
|
||||
bytes2 = size_binop (MINUS_EXPR, pt_var_size, bytes2);
|
||||
bytes = size_binop (MIN_EXPR, bytes, bytes2);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user