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
This commit is contained in:
parent
049e524f68
commit
3274deff9f
@ -1,3 +1,11 @@
|
||||
2004-09-09 James E Wilson <wilson@specifixinc.com>
|
||||
|
||||
* 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 <roger@eyesopen.com>
|
||||
|
||||
PR middle-end/17055
|
||||
|
@ -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;
|
||||
|
@ -1,3 +1,7 @@
|
||||
2004-09-09 James E Wilson <wilson@specifixinc.com>
|
||||
|
||||
* gcc.dg/init-vec-1.c: New test.
|
||||
|
||||
2004-09-09 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
PR middle-end/17055
|
||||
|
4
gcc/testsuite/gcc.dg/init-vec-1.c
Normal file
4
gcc/testsuite/gcc.dg/init-vec-1.c
Normal file
@ -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" } */
|
Loading…
Reference in New Issue
Block a user