OSDN Git Service

PR tree-optimization/39343
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Mar 2009 11:29:51 +0000 (11:29 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Mar 2009 11:29:51 +0000 (11:29 +0000)
* tree-ssa-ccp.c (maybe_fold_offset_to_address): Don't check if
COMPONENT_REF t has ARRAY_TYPE.

* gcc.dg/pr39343.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144571 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr39343.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c

index 998ef44..72da01f 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/39343
+       * tree-ssa-ccp.c (maybe_fold_offset_to_address): Don't check if
+       COMPONENT_REF t has ARRAY_TYPE.
+
 2009-03-02  Sebastian Pop  <sebastian.pop@amd.com>
 
        PR middle-end/39335
index 5d5b967..3bb4d97 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/39343
+       * gcc.dg/pr39343.c: New test.
+
 2009-03-03  Ira Rosen  <irar@il.ibm.com>
 
        PR tree-optimization/39248
diff --git a/gcc/testsuite/gcc.dg/pr39343.c b/gcc/testsuite/gcc.dg/pr39343.c
new file mode 100644 (file)
index 0000000..70df59e
--- /dev/null
@@ -0,0 +1,29 @@
+/* PR tree-optimization/39343 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+extern inline __attribute__ ((__always_inline__)) int
+foo (char *dest)
+{
+  return __builtin_object_size (dest, 1);
+}
+
+struct S
+{
+  union
+  {
+    struct { int a, b; char c, d; } f;
+    struct { struct { int a, b; char c, d[255]; } e; } g;
+  } u;
+};
+
+int
+main (void)
+{
+  struct S s;
+  if (foo (s.u.g.e.d) != 255)
+    abort ();
+  return 0;
+}
index d602726..5080cc3 100644 (file)
@@ -1942,8 +1942,7 @@ maybe_fold_offset_to_address (tree addr, tree offset, tree orig_type)
           || (TREE_CODE (orig) == COMPONENT_REF
               && TREE_CODE (TREE_TYPE (TREE_OPERAND (orig, 1))) == ARRAY_TYPE))
          && (TREE_CODE (t) == ARRAY_REF
-             || (TREE_CODE (t) == COMPONENT_REF
-                 && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 1))) == ARRAY_TYPE))
+             || TREE_CODE (t) == COMPONENT_REF)
          && !operand_equal_p (TREE_CODE (orig) == ARRAY_REF
                               ? TREE_OPERAND (orig, 0) : orig,
                               TREE_CODE (t) == ARRAY_REF