diff options
author | James E Wilson <wilson@specifixinc.com> | 2005-08-16 11:23:58 -0700 |
---|---|---|
committer | Jim Wilson <wilson@gcc.gnu.org> | 2005-08-16 11:23:58 -0700 |
commit | 355a9e437d6bffe505a1d5757f71dccd7f6e74f7 (patch) | |
tree | 294db0f3f5e2ca5c3887b056ddfe2e74d2890bed /gcc | |
parent | 3881a11b4aaa2f38fe7024edcf83eb5238835506 (diff) | |
download | gcc-355a9e437d6bffe505a1d5757f71dccd7f6e74f7.zip gcc-355a9e437d6bffe505a1d5757f71dccd7f6e74f7.tar.gz gcc-355a9e437d6bffe505a1d5757f71dccd7f6e74f7.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-decl.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/large-size-array.c | 21 |
4 files changed, 33 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1c23f85..ecd37e6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index ff35e08..a1fdce7 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a38b710..75ab35f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..e8d9791 --- /dev/null +++ b/gcc/testsuite/gcc.dg/large-size-array.c @@ -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]); +} |