re PR middle-end/51077 (Endless recursion with __builtin_object_size)

PR middle-end/51077
	* tree-object-size.c (addr_object_size): Check TREE_CODE of
	MEM_REF's operand rather than code of the MEM_REF itself.

	* gcc.c-torture/compile/pr51077.c: New test.

From-SVN: r181263
This commit is contained in:
Jakub Jelinek 2011-11-10 20:02:30 +01:00 committed by Jakub Jelinek
parent 8851b42977
commit ea17de23b7
4 changed files with 25 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2011-11-10 Jakub Jelinek <jakub@redhat.com>
PR middle-end/51077
* tree-object-size.c (addr_object_size): Check TREE_CODE of
MEM_REF's operand rather than code of the MEM_REF itself.
2011-11-10 Andrew MacLeod <amacleod@redhat.com>
PR rtl-optimization/51040

View File

@ -1,5 +1,8 @@
2011-11-10 Jakub Jelinek <jakub@redhat.com>
PR middle-end/51077
* gcc.c-torture/compile/pr51077.c: New test.
PR rtl-optimization/51023
* gcc.c-torture/execute/pr51023.c: New test.

View File

@ -0,0 +1,15 @@
/* PR middle-end/51077 */
struct S { unsigned char s, t[256]; };
void
foo (const struct S *x, struct S *y, int z)
{
int i;
for (i = 0; i < 8; i++)
{
const struct S *a = &x[i];
__builtin___memcpy_chk (y->t, a->t, z, __builtin_object_size (y->t, 0));
y = (struct S *) &y->t[z];
}
}

View File

@ -175,7 +175,7 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
unsigned HOST_WIDE_INT sz;
if (!osi || (object_size_type & 1) != 0
|| TREE_CODE (pt_var) != SSA_NAME)
|| TREE_CODE (TREE_OPERAND (pt_var, 0)) != SSA_NAME)
{
sz = compute_builtin_object_size (TREE_OPERAND (pt_var, 0),
object_size_type & ~1);