Changeset 1600 for trunk/src/gcc/gcc/cp/decl.c
- Timestamp:
- Nov 4, 2004, 1:37:17 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gcc/gcc/cp/decl.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1599 r1600 148 148 static void expand_static_init (tree, tree); 149 149 static tree next_initializable_field (tree); 150 static bool reshape_init_array (tree, tree, tree *, tree); 150 151 static tree reshape_init (tree, tree *); 151 152 … … 8227 8228 } 8228 8229 8230 /* Subroutine of reshape_init. Reshape the constructor for an array. INITP 8231 is the pointer to the old constructor list (to the CONSTRUCTOR_ELTS of 8232 the CONSTRUCTOR we are processing), while NEW_INIT is the CONSTRUCTOR we 8233 are building. 8234 ELT_TYPE is the element type of the array. MAX_INDEX is an INTEGER_CST 8235 representing the size of the array minus one (the maximum index), or 8236 NULL_TREE if the array was declared without specifying the size. */ 8237 8238 static bool 8239 reshape_init_array (tree elt_type, tree max_index, 8240 tree *initp, tree new_init) 8241 { 8242 bool sized_array_p = (max_index != NULL_TREE); 8243 HOST_WIDE_INT max_index_cst = 0; 8244 HOST_WIDE_INT index; 8245 8246 if (sized_array_p) 8247 /* HWI is either 32bit or 64bit, so it must be enough to represent the 8248 array size. */ 8249 max_index_cst = tree_low_cst (max_index, 1); 8250 8251 /* Loop until there are no more initializers. */ 8252 for (index = 0; 8253 *initp && (!sized_array_p || index <= max_index_cst); 8254 ++index) 8255 { 8256 tree element_init; 8257 tree designated_index; 8258 8259 element_init = reshape_init (elt_type, initp); 8260 if (element_init == error_mark_node) 8261 return false; 8262 TREE_CHAIN (element_init) = CONSTRUCTOR_ELTS (new_init); 8263 CONSTRUCTOR_ELTS (new_init) = element_init; 8264 designated_index = TREE_PURPOSE (element_init); 8265 if (designated_index) 8266 { 8267 if (TREE_CODE (designated_index) != INTEGER_CST) 8268 abort (); 8269 if (sized_array_p 8270 && tree_int_cst_lt (max_index, designated_index)) 8271 { 8272 error ("Designated initializer `%E' larger than array " 8273 "size", designated_index); 8274 TREE_PURPOSE (element_init) = NULL_TREE; 8275 } 8276 else 8277 index = tree_low_cst (designated_index, 1); 8278 } 8279 } 8280 8281 return true; 8282 } 8283 8229 8284 /* Undo the brace-elision allowed by [dcl.init.aggr] in a 8230 8285 brace-enclosed aggregate initializer. … … 8402 8457 else if ((TREE_CODE (type) == ARRAY_TYPE)|| (TREE_CODE (type) == VECTOR_TYPE)) 8403 8458 { 8404 tree index;8405 8459 tree max_index; 8406 8460 … … 8409 8463 max_index = ((TYPE_DOMAIN (type) && (TREE_CODE (type) == ARRAY_TYPE)) 8410 8464 ? array_type_nelts (type) : NULL_TREE); 8411 /* Loop through the array elements, gathering initializers. */ 8412 for (index = size_zero_node; 8413 *initp && (!max_index || !tree_int_cst_lt (max_index, index)); 8414 index = size_binop (PLUS_EXPR, index, size_one_node)) 8415 { 8416 tree element_init; 8417 8418 element_init = reshape_init (TREE_TYPE (type), initp); 8419 if (element_init == error_mark_node) 8420 return error_mark_node; 8421 TREE_CHAIN (element_init) = CONSTRUCTOR_ELTS (new_init); 8422 CONSTRUCTOR_ELTS (new_init) = element_init; 8423 if (TREE_PURPOSE (element_init)) 8424 index = convert (sizetype, TREE_PURPOSE (element_init)); 8425 } 8465 if (!reshape_init_array (TREE_TYPE (type), max_index, 8466 initp, new_init)) 8467 return error_mark_node; 8426 8468 } 8427 8469 else -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.