From 7f4d6e1beb079e85cf99fc1f4df2e1732beda67c Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Mon, 14 Mar 2011 12:20:48 +0000 Subject: [PATCH] re PR tree-optimization/48098 (internal compiler error: in build_vector_from_val, at tree.c:1380) 2011-03-14 Richard Guenther PR middle-end/48098 * tree.c (build_vector_from_val): Adjust assert to requirements and reality. * gcc.dg/torture/pr48098.c: New testcase. From-SVN: r170934 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr48098.c | 12 ++++++++++++ gcc/tree.c | 10 ++++++++-- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr48098.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bedecefd683a..086d1ba44aae 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-03-14 Richard Guenther + + PR middle-end/48098 + * tree.c (build_vector_from_val): Adjust assert to requirements + and reality. + 2011-03-14 Jakub Jelinek PR bootstrap/48102 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0ea094682b01..2356b1de1700 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-03-14 Richard Guenther + + PR middle-end/48098 + * gcc.dg/torture/pr48098.c: New testcase. + 2011-03-12 Peter Bergner PR target/48053 diff --git a/gcc/testsuite/gcc.dg/torture/pr48098.c b/gcc/testsuite/gcc.dg/torture/pr48098.c new file mode 100644 index 000000000000..cd72939374fa --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr48098.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +void +foo (int n) +{ + static char *__restrict *p; + int i; + p = __builtin_malloc (n); + for (i = 0; i < n; i++) + p[i] = 0; +} + diff --git a/gcc/tree.c b/gcc/tree.c index be469909995b..405b5499502e 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1376,8 +1376,14 @@ build_vector_from_val (tree vectype, tree sc) if (sc == error_mark_node) return sc; - gcc_assert (useless_type_conversion_p (TREE_TYPE (sc), - TREE_TYPE (vectype))); + /* Verify that the vector type is suitable for SC. Note that there + is some inconsistency in the type-system with respect to restrict + qualifications of pointers. Vector types always have a main-variant + element type and the qualification is applied to the vector-type. + So TREE_TYPE (vector-type) does not return a properly qualified + vector element-type. */ + gcc_checking_assert (types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (sc)), + TREE_TYPE (vectype))); v = VEC_alloc (constructor_elt, gc, nunits); for (i = 0; i < nunits; ++i)