diff options
author | James E Wilson <wilson@specifixinc.com> | 2004-09-10 03:51:40 +0000 |
---|---|---|
committer | Jim Wilson <wilson@gcc.gnu.org> | 2004-09-09 20:51:40 -0700 |
commit | 3274deff9fbb7530ef76ba973070d696696d20ec (patch) | |
tree | 1c4bb669ecba87bd3145ccb5f02df805439797e1 /gcc | |
parent | 049e524f68be57df307f11ea9d3d28afdc37d7c3 (diff) | |
download | gcc-3274deff9fbb7530ef76ba973070d696696d20ec.zip gcc-3274deff9fbb7530ef76ba973070d696696d20ec.tar.gz gcc-3274deff9fbb7530ef76ba973070d696696d20ec.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/c-typeck.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/init-vec-1.c | 4 |
4 files changed, 22 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a6105a8..1b7f107 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 4cfd7ce..a815e2f 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 bf369b9..1dbc50a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 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 0000000..9921b16 --- /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" } */ |