From 4aeeff51bbee421301ebf6fdd2002c2ef1b4723f Mon Sep 17 00:00:00 2001 From: sayle Date: Fri, 28 Apr 2006 19:59:57 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113355 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/c-typeck.c | 13 ++++++------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/large-size-array-2.c | 7 +++++++ 4 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/large-size-array-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b7ab6312c0d..99f3503bcee 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2006-04-28 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-04-28 Joseph S. Myers * gcc.c (process_command): Add program name to GCC_EXEC_PREFIX diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 21fe12538a2..64fa9f15336 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -90,7 +90,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 *); @@ -4309,7 +4308,7 @@ struct spelling int kind; union { - int i; + unsigned HOST_WIDE_INT i; const char *s; } u; }; @@ -4369,7 +4368,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); } @@ -4404,7 +4403,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 @@ -5083,7 +5082,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 @@ -5200,7 +5199,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++; } @@ -6588,7 +6587,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 9f2b6e71102..5a7ccc9e745 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-04-28 Roger Sayle + + PR c/25309 + * gcc.dg/large-size-array-2.c: New test case. + 2006-04-28 Richard Guenther PR target/26826 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 00000000000..6ac31d11af4 --- /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" + }; + -- 2.11.0