OSDN Git Service

* typeck2.c (digest_init, process_init_constructor): Treat vectors
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Feb 2002 12:05:01 +0000 (12:05 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Feb 2002 12:05:01 +0000 (12:05 +0000)
        like arrays.

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

gcc/cp/ChangeLog
gcc/cp/typeck2.c

index f6c2a54..3ee3f76 100644 (file)
@@ -1,3 +1,8 @@
+2002-02-13  Jason Merrill  <jason@redhat.com>
+
+       * typeck2.c (digest_init, process_init_constructor): Treat vectors
+       like arrays.
+
 2002-02-11  Jason Merrill  <jason@redhat.com>
 
        * parse.y (reserved_declspecs): Don't handle attributes.
index 314685a..1ade13c 100644 (file)
@@ -544,7 +544,7 @@ digest_init (type, init, tail)
 
   if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
       || code == ENUMERAL_TYPE || code == REFERENCE_TYPE
-      || code == BOOLEAN_TYPE || code == COMPLEX_TYPE || code == VECTOR_TYPE
+      || code == BOOLEAN_TYPE || code == COMPLEX_TYPE
       || TYPE_PTRMEMFUNC_P (type))
     {
       if (raw_constructor)
@@ -578,7 +578,7 @@ digest_init (type, init, tail)
       return error_mark_node;
     }
 
-  if (code == ARRAY_TYPE || IS_AGGR_TYPE_CODE (code))
+  if (code == ARRAY_TYPE || code == VECTOR_TYPE || IS_AGGR_TYPE_CODE (code))
     {
       if (raw_constructor && TYPE_NON_AGGREGATE_CLASS (type)
          && TREE_HAS_CONSTRUCTOR (init))
@@ -598,7 +598,7 @@ digest_init (type, init, tail)
          return process_init_constructor (type, 0, tail);
        }
 
-      if (code != ARRAY_TYPE)
+      if (CLASS_TYPE_P (type))
        {
          int flags = LOOKUP_NORMAL;
          /* Initialization from { } is copy-initialization.  */
@@ -659,18 +659,26 @@ process_init_constructor (type, init, elts)
      for each element of this aggregate.  Chain them together in result.
      If there are too few, use 0 for each scalar ultimate component.  */
 
-  if (TREE_CODE (type) == ARRAY_TYPE)
+  if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == VECTOR_TYPE)
     {
-      tree domain = TYPE_DOMAIN (type);
       register long len;
       register int i;
 
-      if (domain)
-       len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain))
-              - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain))
-              + 1);
+      if (TREE_CODE (type) == ARRAY_TYPE)
+       {
+         tree domain = TYPE_DOMAIN (type);
+         if (domain)
+           len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain))
+                  - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain))
+                  + 1);
+         else
+           len = -1;  /* Take as many as there are */
+       }
       else
-       len = -1;  /* Take as many as there are */
+       {
+         /* Vectors are like simple fixed-size arrays.  */
+         len = TYPE_VECTOR_SUBPARTS (type);
+       }
 
       for (i = 0; len < 0 || i < len; i++)
        {