Emit an error for too large arrays instead of an ICE.

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
This commit is contained in:
James E Wilson 2005-08-16 11:23:58 -07:00 committed by Jim Wilson
parent 3881a11b4a
commit 355a9e437d
4 changed files with 33 additions and 1 deletions

View 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.

View 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

View 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

View File

@ -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]);
}