re PR middle-end/51077 (Endless recursion with __builtin_object_size)
authorJakub Jelinek <jakub@redhat.com>
Thu, 10 Nov 2011 19:02:30 +0000 (20:02 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 10 Nov 2011 19:02:30 +0000 (20:02 +0100)
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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr51077.c [new file with mode: 0644]
gcc/tree-object-size.c

index fa7cbeb1bb55a0968ae4c4553457e0a901142f5a..b07dbca042d1b1517cd1508f23722ca8b200e6c6 100644 (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
index ffa8b57d8fa3b9043021adffe529542c0c5593fb..9615be5b53bca1273276b26019c8082d807ee5fb 100644 (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.
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr51077.c b/gcc/testsuite/gcc.c-torture/compile/pr51077.c
new file mode 100644 (file)
index 0000000..de2b97e
--- /dev/null
@@ -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];
+    }
+}
index 017f8c5e933c9c1b9ed54b9c71c3ef4baf8e26c5..326b2e4c21b0645986622e17ca4954537adb0e0e 100644 (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);