OSDN Git Service

Emit an error for too large arrays instead of an ICE.
authorwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Aug 2005 18:23:58 +0000 (18:23 +0000)
committerwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Aug 2005 18:23:58 +0000 (18:23 +0000)
PR tree-optimization/21105
* c-decl.c (grokdeclarator): Use TYPE_SIZE_UNIT not TYPE_SIZE in
TREE_OVERFLOW check.
* gcc.dg/large-size-array.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@103164 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 1c23f85..ecd37e6 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-16  James E Wilson  <wilson@specifix.com>
+
+       PR tree-optimization/21105
+       * c-decl.c (grokdeclarator): Use TYPE_SIZE_UNIT not TYPE_SIZE in
+       TREE_OVERFLOW check.
+
 2005-08-16  David Edelsohn  <edelsohn@gnu.org>
 
        * config/rs6000/rs6000.md (ltu<mode>): Convert to mode macro.
index ff35e08..a1fdce7 100644 (file)
@@ -4384,7 +4384,7 @@ grokdeclarator (const struct c_declarator *declarator,
   if (TREE_CODE (type) == ARRAY_TYPE
       && COMPLETE_TYPE_P (type)
       && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
-      && TREE_OVERFLOW (TYPE_SIZE (type)))
+      && TREE_OVERFLOW (TYPE_SIZE_UNIT (type)))
     {
       error ("size of array %qs is too large", name);
       /* If we proceed with the array type as it is, we'll eventually
index a38b710..75ab35f 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-16  James E Wilson  <wilson@specifix.com>
+
+       PR tree-optimization/21105
+       * gcc.dg/large-size-array.c: New.
+
 2005-08-16  Dorit Nuzman  <dorit@il.ibm.com>
 
        * gcc.dg/vect/vect-40: Use aligned arrays instead of arrays to aligned
diff --git a/gcc/testsuite/gcc.dg/large-size-array.c b/gcc/testsuite/gcc.dg/large-size-array.c
new file mode 100644 (file)
index 0000000..e8d9791
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+#include <limits.h>
+
+#ifdef __LP64__
+#define DIM UINT_MAX>>1
+#else
+#define DIM USHORT_MAX>>1
+#endif
+
+int
+sub (int *a)
+{
+  return a[0];
+}
+
+int
+main (void)
+{
+  int a[DIM][DIM];  /* { dg-error "size of array 'a' is too large" } */
+  return sub (&a[0][0]);
+}