]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/25309 (ICE on initialization of a huge array)
authorRoger Sayle <roger@eyesopen.com>
Wed, 3 May 2006 18:49:40 +0000 (18:49 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Wed, 3 May 2006 18:49:40 +0000 (18:49 +0000)
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

gcc/ChangeLog
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/large-size-array-2.c [new file with mode: 0644]

index 6150d5c8714f8761d74a71c4fafb2b3af2841707..0c5f5893ac26d2401b20aa51082846f8796b808b 100644 (file)
@@ -1,3 +1,17 @@
+2006-05-03  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-05-01  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/26565
index 94df4216ae397827558d0f540a45a6606fd848ec..28a6f70e5a4e36d861560b6fe31e96ca08d19ca3 100644 (file)
@@ -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);
index 6f03322197bcae39a3b9ee989f01811fc5958061..652e76b3fe063bc77241373a0d66ad47e55d3c61 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-03  Roger Sayle  <roger@eyesopen.com>
+
+       PR c/25309
+       * gcc.dg/large-size-array-2.c: New test case.
+
 2006-04-30  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        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 (file)
index 0000000..6ac31d1
--- /dev/null
@@ -0,0 +1,7 @@
+/* PR c/25309 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+static char * name[] = {
+    [0x80000000]  = "bar"
+  };
+