From: Roger Sayle Date: Wed, 3 May 2006 18:49:40 +0000 (+0000) Subject: re PR c/25309 (ICE on initialization of a huge array) X-Git-Tag: releases/gcc-4.0.4~726 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4254d38155ccc44f7cd3a12448766f87ec576781;p=thirdparty%2Fgcc.git re PR c/25309 (ICE on initialization of a huge array) PR c/25309 * c-typeck.c (struct spelling): Make I an unsigned HOST_WIDE_INT. (push_array_bounds): Delete prototype. Change BOUNDS argument to an unsigned HOST_WIDE_INT. (print_spelling): Use HOST_WIDE_INT_PRINT_UNSIGNED to output the array index. (really_start_incremental_init): No need to call convert because bitsize_zero_node is already of type bitsizetype. (push_init_level): Extract the value of constructor_index as an unsigned HOST_WIDE_INT quantity, using tree_low_cst. (process_init_element): Likewise. * gcc.dg/large-size-array-2.c: New test case. From-SVN: r113500 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6150d5c8714f..0c5f5893ac26 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2006-05-03 Roger Sayle + + PR c/25309 + * c-typeck.c (struct spelling): Make I an unsigned HOST_WIDE_INT. + (push_array_bounds): Delete prototype. Change BOUNDS argument to + an unsigned HOST_WIDE_INT. + (print_spelling): Use HOST_WIDE_INT_PRINT_UNSIGNED to output the + array index. + (really_start_incremental_init): No need to call convert because + bitsize_zero_node is already of type bitsizetype. + (push_init_level): Extract the value of constructor_index as an + unsigned HOST_WIDE_INT quantity, using tree_low_cst. + (process_init_element): Likewise. + 2006-05-01 Richard Guenther PR middle-end/26565 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 94df4216ae39..28a6f70e5a4e 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -89,7 +89,6 @@ static tree convert_for_assignment (tree, tree, enum impl_conv, tree, tree, static tree valid_compound_expr_initializer (tree, tree); static void push_string (const char *); static void push_member_name (tree); -static void push_array_bounds (int); static int spelling_length (void); static char *print_spelling (char *); static void warning_init (const char *); @@ -4023,7 +4022,7 @@ struct spelling int kind; union { - int i; + unsigned HOST_WIDE_INT i; const char *s; } u; }; @@ -4083,7 +4082,7 @@ push_member_name (tree decl) /* Push an array bounds on the stack. Printed as [BOUNDS]. */ static void -push_array_bounds (int bounds) +push_array_bounds (unsigned HOST_WIDE_INT bounds) { PUSH_SPELLING (SPELLING_BOUNDS, bounds, u.i); } @@ -4118,7 +4117,7 @@ print_spelling (char *buffer) for (p = spelling_base; p < spelling; p++) if (p->kind == SPELLING_BOUNDS) { - sprintf (d, "[%d]", p->u.i); + sprintf (d, "[" HOST_WIDE_INT_PRINT_UNSIGNED "]", p->u.i); d += strlen (d); } else @@ -4791,7 +4790,7 @@ really_start_incremental_init (tree type) /* Vectors are like simple fixed-size arrays. */ constructor_max_index = build_int_cst (NULL_TREE, TYPE_VECTOR_SUBPARTS (constructor_type) - 1); - constructor_index = convert (bitsizetype, bitsize_zero_node); + constructor_index = bitsize_zero_node; constructor_unfilled_index = constructor_index; } else @@ -4908,7 +4907,7 @@ push_init_level (int implicit) else if (TREE_CODE (constructor_type) == ARRAY_TYPE) { constructor_type = TREE_TYPE (constructor_type); - push_array_bounds (tree_low_cst (constructor_index, 0)); + push_array_bounds (tree_low_cst (constructor_index, 1)); constructor_depth++; } @@ -6313,7 +6312,7 @@ process_init_element (struct c_expr value) /* Now output the actual element. */ if (value.value) { - push_array_bounds (tree_low_cst (constructor_index, 0)); + push_array_bounds (tree_low_cst (constructor_index, 1)); output_init_element (value.value, strict_string, elttype, constructor_index, 1); RESTORE_SPELLING_DEPTH (constructor_depth); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6f03322197bc..652e76b3fe06 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-05-03 Roger Sayle + + PR c/25309 + * gcc.dg/large-size-array-2.c: New test case. + 2006-04-30 Volker Reichelt PR c++/27278 diff --git a/gcc/testsuite/gcc.dg/large-size-array-2.c b/gcc/testsuite/gcc.dg/large-size-array-2.c new file mode 100644 index 000000000000..6ac31d11af42 --- /dev/null +++ b/gcc/testsuite/gcc.dg/large-size-array-2.c @@ -0,0 +1,7 @@ +/* PR c/25309 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +static char * name[] = { + [0x80000000] = "bar" + }; +