summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-07-29 12:31:29 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-07-29 12:31:29 +0000
commit6207b4f9d5f30e15e6883a797456bd456f4cf780 (patch)
treed6a0b4eca69ba92d9f1bd7793ead87989b748a15 /gcc
parent726c2801df3c37ba209be9f2052d22e9d098fdb1 (diff)
downloadgcc-6207b4f9d5f30e15e6883a797456bd456f4cf780.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162677 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/tree.c7
2 files changed, 13 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 45155e417f5..44353ab7ec8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
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
* tree-ssa-structalias.c (get_constraint_for_component_ref):
Handle offset in DEREFs properly.
diff --git a/gcc/tree.c b/gcc/tree.c
index a33f22b40f5..f40114575e8 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -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));
}