re PR c/29091 (vector constant not fully outputed)
authorJakub Jelinek <jakub@redhat.com>
Fri, 6 Oct 2006 07:15:48 +0000 (09:15 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 6 Oct 2006 07:15:48 +0000 (09:15 +0200)
PR c/29091
* varasm.c (output_constant): If TREE_VECTOR_CST_ELTS chain is shorter than
the number of vector elements fill the rest with zeros.

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

From-SVN: r117481

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr29091.c [new file with mode: 0644]
gcc/varasm.c

index 3ae2d25f34a7eb2668e166cea4b89375adb31ad1..3eaecfedff3bf89163899479e714c4cd49f4d0a7 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/29091
+       * varasm.c (output_constant): If TREE_VECTOR_CST_ELTS chain is shorter than
+       the number of vector elements fill the rest with zeros.
+
 2006-10-05  Richard Sandiford  <richard@codesourcery.com>
 
        * config/mips/mips.c (mips_pass_by_reference): Do not return false
index 31ba8d4b03be2a3c7e9daaaad0513080bd9c79ae..7fb74e74363d1c23508496deb72566e2e6fa7253 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/29091
+       * gcc.dg/pr29091.c: New test.
+
 2006-10-06  Joseph Myers  <joseph@codesourcery.com>
 
        * lib/target-supports.exp
diff --git a/gcc/testsuite/gcc.dg/pr29091.c b/gcc/testsuite/gcc.dg/pr29091.c
new file mode 100644 (file)
index 0000000..6e06c63
--- /dev/null
@@ -0,0 +1,44 @@
+/* PR c/29091 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+__attribute__ ((vector_size (sizeof (int) * 4))) int a = { 1, 2 };
+int d = 3;
+__attribute__ ((vector_size (sizeof (int) * 4))) int b = { 4, 5, 6 };
+int e = 7;
+__attribute__ ((vector_size (sizeof (int) * 4))) int c = { };
+
+int
+main (void)
+{
+  int *p = (int *) &a;
+  if (p[0] != 1)
+    abort ();
+  if (p[1] != 2)
+    abort ();
+  if (p[2] != 0)
+    abort ();
+  if (p[3] != 0)
+    abort ();
+  p = (int *) &b;
+  if (p[0] != 4)
+    abort ();
+  if (p[1] != 5)
+    abort ();
+  if (p[2] != 6)
+    abort ();
+  if (p[3] != 0)
+    abort ();
+  p = (int *) &c;
+  if (p[0] != 0)
+    abort ();
+  if (p[1] != 0)
+    abort ();
+  if (p[2] != 0)
+    abort ();
+  if (p[3] != 0)
+    abort ();
+  return 0;
+}
index ff3e443ef2cd82074ce0307d2705a4c67e419a2b..d14dc7018c8d3b293ad79bd0005673fd5c024e0e 100644 (file)
@@ -4403,8 +4403,12 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align)
 
            link = TREE_VECTOR_CST_ELTS (exp);
            output_constant (TREE_VALUE (link), elt_size, align);
+           thissize = elt_size;
            while ((link = TREE_CHAIN (link)) != NULL)
-             output_constant (TREE_VALUE (link), elt_size, nalign);
+             {
+               output_constant (TREE_VALUE (link), elt_size, nalign);
+               thissize += elt_size;
+             }
            break;
          }
        default: