]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree.c (build_vector): Assert that the vector constant has enough elements.
authorRichard Guenther <rguenther@suse.de>
Thu, 29 Jul 2010 12:31:29 +0000 (12:31 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 29 Jul 2010 12:31:29 +0000 (12:31 +0000)
2010-07-29  Richard Guenther  <rguenther@suse.de>

* tree.c (build_vector): Assert that the vector constant
has enough elements.
(build_vector_from_ctor): Pad with trailing zeros.

From-SVN: r162677

gcc/ChangeLog
gcc/tree.c

index 45155e417f5ab9fe8b75eb5e57d472de570b4dda..44353ab7ec82d30caf892203b0f2cc96a4d67ff8 100644 (file)
@@ -1,3 +1,9 @@
+2010-07-29  Richard Guenther  <rguenther@suse.de>
+
+       * tree.c (build_vector): Assert that the vector constant
+       has enough elements.
+       (build_vector_from_ctor): Pad with trailing zeros.
+
 2010-07-29  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/45120
index a33f22b40f5843898e7a22a0e099a669b9d03c81..f40114575e88e72310569f778f7267a79ba642d4 100644 (file)
@@ -1318,6 +1318,7 @@ build_vector (tree type, tree vals)
   tree v = make_node (VECTOR_CST);
   int over = 0;
   tree link;
+  unsigned cnt = 0;
 
   TREE_VECTOR_CST_ELTS (v) = vals;
   TREE_TYPE (v) = type;
@@ -1326,6 +1327,7 @@ build_vector (tree type, tree vals)
   for (link = vals; link; link = TREE_CHAIN (link))
     {
       tree value = TREE_VALUE (link);
+      cnt++;
 
       /* Don't crash if we get an address constant.  */
       if (!CONSTANT_CLASS_P (value))
@@ -1334,6 +1336,8 @@ build_vector (tree type, tree vals)
       over |= TREE_OVERFLOW (value);
     }
 
+  gcc_assert (cnt == TYPE_VECTOR_SUBPARTS (type));
+
   TREE_OVERFLOW (v) = over;
   return v;
 }
@@ -1350,6 +1354,9 @@ build_vector_from_ctor (tree type, VEC(constructor_elt,gc) *v)
 
   FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value)
     list = tree_cons (NULL_TREE, value, list);
+  for (; idx < TYPE_VECTOR_SUBPARTS (type); ++idx)
+    list = tree_cons (NULL_TREE,
+                     fold_convert (TREE_TYPE (type), integer_zero_node), list);
   return build_vector (type, nreverse (list));
 }