OSDN Git Service

Fix ICE on invalid input, and eliminate confusing error message.
authorwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 10 Sep 2004 03:51:40 +0000 (03:51 +0000)
committerwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 10 Sep 2004 03:51:40 +0000 (03:51 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87273 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/init-vec-1.c [new file with mode: 0644]

index a6105a8..1b7f107 100644 (file)
@@ -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
 2004-09-09  Roger Sayle  <roger@eyesopen.com>
 
        PR middle-end/17055
index 4cfd7ce..a815e2f 100644 (file)
@@ -3407,7 +3407,7 @@ convert_for_assignment (tree type, tree rhs, const char *errtype,
       return rhs;
     }
   /* Some types can interconvert without explicit casts.  */
       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.  */
            && 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
      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))
       {
         && 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);
 
        = 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;
        {
          error_init ("initializer element is not constant");
          inside_init = error_mark_node;
index bf369b9..1dbc50a 100644 (file)
@@ -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
 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 (file)
index 0000000..9921b16
--- /dev/null
@@ -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" } */