]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/38505 (Revision 142061 caused ICE on __builtin_memcpy)
authorJakub Jelinek <jakub@redhat.com>
Thu, 18 Dec 2008 07:52:07 +0000 (08:52 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 18 Dec 2008 07:52:07 +0000 (08:52 +0100)
PR middle-end/38505
* tree-ssa.c (useless_type_conversion_p_1): Return
false if inner_type is incomplete and outer_type is complete.

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

From-SVN: r142806

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr38505.c [new file with mode: 0644]
gcc/tree-ssa.c

index df3ced5215ff352e42e5d2d10d16f40e73a84e56..49176895d4844a743c6774f5141667ae8539a0a8 100644 (file)
@@ -1,3 +1,9 @@
+2008-12-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/38505
+       * tree-ssa.c (useless_type_conversion_p_1): Return
+       false if inner_type is incomplete and outer_type is complete.
+
 2008-12-17  Sebastian Pop  <sebastian.pop@amd.com>
        
         * doc/install.texi (Prerequisites): Document PPL and CLooG-PPL
index 11a6a70953142a0ed52c9652c40c85946512d6d4..0bf69e2562b4c7240ecc5f6970b33a8b0c44ba47 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/38505
+       * gcc.c-torture/compile/pr38505.c: New test.
+
 2008-12-17  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/auto6.C: Test more stuff.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr38505.c b/gcc/testsuite/gcc.c-torture/compile/pr38505.c
new file mode 100644 (file)
index 0000000..b3b4a10
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR middle-end/38505 */
+/* { dg-do compile } */
+
+struct S
+{
+  unsigned short a[50];
+  unsigned short b[20];
+};
+extern void bar (struct S *);
+extern void baz (unsigned short *);
+extern unsigned short d[];
+
+void
+foo (void)
+{
+  struct S s;
+  unsigned short g[50];
+
+  baz (g);
+  __builtin_memcpy (&s, g, sizeof (g));
+  __builtin_memcpy (s.b, d, sizeof (s.b));
+  bar (&s);
+}
index 935cad676c14a240844bcc0bb40bece2b4c8d12e..ce0f1e4ee67b4fcfde8993f0fbbfdd358ba89577 100644 (file)
@@ -1188,6 +1188,11 @@ useless_type_conversion_p_1 (tree outer_type, tree inner_type)
       if (TREE_CODE (inner_type) != TREE_CODE (outer_type))
        return false;
 
+      /* Conversion from an incomplete to a complete type is never
+        useless.  */
+      if (!COMPLETE_TYPE_P (inner_type) && COMPLETE_TYPE_P (outer_type))
+       return false;
+
       /* ???  This seems to be necessary even for aggregates that don't
         have TYPE_STRUCTURAL_EQUALITY_P set.  */