OSDN Git Service

PR middle-end/51077
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Nov 2011 19:04:01 +0000 (19:04 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Nov 2011 19:04:01 +0000 (19:04 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@181264 138bc75d-0d04-0410-961f-82ee72b054a4

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

index d9f944b..cca4125 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-07  Alan Modra  <amodra@gmail.com>
 
        PR target/30282
index 3951c66..dd7356c 100644 (file)
@@ -1,3 +1,8 @@
+2011-11-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/51077
+       * gcc.c-torture/compile/pr51077.c: New test.
+
 2011-11-07  Jason Merrill  <jason@redhat.com>
 
        PR c++/50870
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 a236281..118f6d5 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);