OSDN Git Service

PR c/25309
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 28 Apr 2006 19:59:57 +0000 (19:59 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 28 Apr 2006 19:59:57 +0000 (19:59 +0000)
* 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
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/large-size-array-2.c [new file with mode: 0644]

index b7ab631..99f3503 100644 (file)
@@ -1,3 +1,17 @@
+2006-04-28  Roger Sayle  <roger@eyesopen.com>
+
+       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  <joseph@codesourcery.com>
 
        * gcc.c (process_command): Add program name to GCC_EXEC_PREFIX
index 21fe125..64fa9f1 100644 (file)
@@ -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);
index 9f2b6e7..5a7ccc9 100644 (file)
@@ -1,3 +1,8 @@
+2006-04-28  Roger Sayle  <roger@eyesopen.com>
+
+       PR c/25309
+       * gcc.dg/large-size-array-2.c: New test case.
+
 2006-04-28  Richard Guenther  <rguenther@suse.de>
 
        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 (file)
index 0000000..6ac31d1
--- /dev/null
@@ -0,0 +1,7 @@
+/* PR c/25309 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+static char * name[] = {
+    [0x80000000]  = "bar"
+  };
+