]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Emit an error for too large arrays instead of an ICE.
authorJames E Wilson <wilson@specifixinc.com>
Tue, 16 Aug 2005 18:23:58 +0000 (11:23 -0700)
committerJim Wilson <wilson@gcc.gnu.org>
Tue, 16 Aug 2005 18:23:58 +0000 (11:23 -0700)
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.

From-SVN: r103164

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

index 1c23f858125e795f0c97e5ac3bf9ebe1be68ad8c..ecd37e67aa22cbc9afa7011898bab7cb7154194f 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 ff35e084be7be998c97923a38583a467ebe4ca2d..a1fdce776a218e86e59aca52eb04d2685ca89ca5 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 a38b71071a7170367753cfb8a0b33e62831fee6e..75ab35f69630cd97ce3e72ba57fff1cb2d7e7f83 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]);
+}