Commit ded97380 by Jakub Jelinek Committed by Jakub Jelinek

tree-object-size.c (addr_object_size): Always use object_size_type 0 or 2 when…

tree-object-size.c (addr_object_size): Always use object_size_type 0 or 2 when determining the pointer pointed object size.

	* tree-object-size.c (addr_object_size): Always use object_size_type
	0 or 2 when determining the pointer pointed object size.

	* gcc.dg/builtin-object-size-9.c: New test.

From-SVN: r151323
parent 683ebd75
2009-09-02 Jakub Jelinek <jakub@redhat.com>
* tree-object-size.c (addr_object_size): Always use object_size_type
0 or 2 when determining the pointer pointed object size.
2009-09-02 Richard Guenther <rguenther@suse.de> 2009-09-02 Richard Guenther <rguenther@suse.de>
Revert Revert
......
2009-09-02 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/builtin-object-size-9.c: New test.
2009-09-02 Olivier Hainque <hainque@adacore.com> 2009-09-02 Olivier Hainque <hainque@adacore.com>
* gnat.dg/array7.ad[bs]: Add check for Signed_Integer_Type_Definition. * gnat.dg/array7.ad[bs]: Add check for Signed_Integer_Type_Definition.
......
/* { dg-do run } */
/* { dg-options "-O2" } */
typedef __SIZE_TYPE__ size_t;
extern void *malloc (size_t);
extern void free (void *);
extern void abort (void);
union U
{
struct S { int a; int b; } s;
int t;
};
struct T
{
int c;
char d[1];
};
int
main (void)
{
union U *u = malloc (sizeof (struct S) + sizeof (struct T) + 6);
struct T *t = (struct T *) (&u->s + 1);
if (__builtin_object_size (t->d, 1)
!= sizeof (struct T) + 6 - __builtin_offsetof (struct T, d))
abort ();
free (u);
return 0;
}
...@@ -171,9 +171,9 @@ addr_object_size (struct object_size_info *osi, const_tree ptr, ...@@ -171,9 +171,9 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
{ {
unsigned HOST_WIDE_INT sz; unsigned HOST_WIDE_INT sz;
if (!osi) if (!osi || (object_size_type & 1) != 0)
sz = compute_builtin_object_size (TREE_OPERAND (pt_var, 0), sz = compute_builtin_object_size (TREE_OPERAND (pt_var, 0),
object_size_type); object_size_type & ~1);
else else
{ {
tree var = TREE_OPERAND (pt_var, 0); tree var = TREE_OPERAND (pt_var, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment