From: James E Wilson Date: Fri, 10 Sep 2004 03:51:40 +0000 (+0000) Subject: Fix ICE on invalid input, and eliminate confusing error message. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3274deff9fbb7530ef76ba973070d696696d20ec;p=gcc.git Fix ICE on invalid input, and eliminate confusing error message. * c-typeck.c (convert_for_assignment): Check that rhs has VECTOR_TYPE before calling vector_types_convertible_p. (digest_init): Check that inside_init has VECTOR_TYPE before calling vector_types_convertible_p. Don't give another error if convert_for_assignment returns error_mark_node. From-SVN: r87273 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a6105a8b7d4..1b7f10751dc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2004-09-09 James E Wilson + + * c-typeck.c (convert_for_assignment): Check that rhs has VECTOR_TYPE + before calling vector_types_convertible_p. + (digest_init): Check that inside_init has VECTOR_TYPE before calling + vector_types_convertible_p. Don't give another error if + convert_for_assignment returns error_mark_node. + 2004-09-09 Roger Sayle PR middle-end/17055 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 4cfd7ce35b5..a815e2f1193 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -3407,7 +3407,7 @@ convert_for_assignment (tree type, tree rhs, const char *errtype, return rhs; } /* Some types can interconvert without explicit casts. */ - else if (codel == VECTOR_TYPE + else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE && vector_types_convertible_p (type, TREE_TYPE (rhs))) return convert (type, rhs); /* Arithmetic types all interconvert, and enum is treated like int. */ @@ -4082,6 +4082,7 @@ digest_init (tree type, tree init, bool strict_string, int require_constant) vector constructor is not constant (e.g. {1,2,3,foo()}) then punt below and handle as a constructor. */ if (code == VECTOR_TYPE + && TREE_CODE (TREE_TYPE (inside_init)) == VECTOR_TYPE && vector_types_convertible_p (TREE_TYPE (inside_init), type) && TREE_CONSTANT (inside_init)) { @@ -4188,7 +4189,10 @@ digest_init (tree type, tree init, bool strict_string, int require_constant) = convert_for_assignment (type, init, _("initialization"), NULL_TREE, NULL_TREE, 0); - if (require_constant && ! TREE_CONSTANT (inside_init)) + /* Check to see if we have already given an error message. */ + if (inside_init == error_mark_node) + ; + else if (require_constant && ! TREE_CONSTANT (inside_init)) { error_init ("initializer element is not constant"); inside_init = error_mark_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bf369b92f82..1dbc50a01d5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-09-09 James E Wilson + + * gcc.dg/init-vec-1.c: New test. + 2004-09-09 Roger Sayle PR middle-end/17055 diff --git a/gcc/testsuite/gcc.dg/init-vec-1.c b/gcc/testsuite/gcc.dg/init-vec-1.c new file mode 100644 index 00000000000..9921b16a91e --- /dev/null +++ b/gcc/testsuite/gcc.dg/init-vec-1.c @@ -0,0 +1,4 @@ +/* Don't ICE or emit spurious errors when init a vector with a scalar. */ +/* { dg-do compile } */ +typedef float v2sf __attribute__ ((vector_size (8))); +v2sf a = 0.0; /* { dg-error "incompatible types" } */