diff options
author | Jason Merrill <jason@redhat.com> | 2002-02-13 07:05:01 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2002-02-13 07:05:01 -0500 |
commit | ca4feb54ab422851b4d165d6c7f522f6ced113eb (patch) | |
tree | bf1c3e8a51d86734ca621aa826ae3af9f414ce1b /gcc | |
parent | aebfea10bedac8653e199c2d9cb6442184d2eb22 (diff) | |
download | gcc-ca4feb54ab422851b4d165d6c7f522f6ced113eb.zip gcc-ca4feb54ab422851b4d165d6c7f522f6ced113eb.tar.gz gcc-ca4feb54ab422851b4d165d6c7f522f6ced113eb.tar.bz2 |
typeck2.c (digest_init, [...]): Treat vectors like arrays.
* typeck2.c (digest_init, process_init_constructor): Treat vectors
like arrays.
From-SVN: r49726
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 28 |
2 files changed, 23 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f6c2a54..3ee3f76 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 314685a..1ade13c 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -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++) { |