summaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-05-03 08:48:00 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2011-05-03 08:48:00 +0000
commit60a45536f1179f87632fb4f8c52ce0891f3a43a9 (patch)
tree570148c322dc5167165f0bfd7d9b64198c1a2065 /gcc/c-decl.c
parent539d6b4aec3bbbcacf918db6edb57fe7c65e54d8 (diff)
downloadgcc-60a45536f1179f87632fb4f8c52ce0891f3a43a9.tar.gz
c-decl.c (grokdeclarator): Instead of looking at TREE_OVERFLOW check if the constant fits in the index type.
2011-05-03 Richard Guenther <rguenther@suse.de> * c-decl.c (grokdeclarator): Instead of looking at TREE_OVERFLOW check if the constant fits in the index type. * gcc.dg/large-size-array-5.c: New testcase. From-SVN: r173297
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 9c6cc90d11a..008f4c65c76 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -5368,15 +5368,13 @@ grokdeclarator (const struct c_declarator *declarator,
convert (index_type,
size_one_node));
- /* If that overflowed, the array is too big. ???
- While a size of INT_MAX+1 technically shouldn't
- cause an overflow (because we subtract 1), the
- overflow is recorded during the conversion to
- index_type, before the subtraction. Handling
- this case seems like an unnecessary
- complication. */
- if (TREE_CODE (itype) == INTEGER_CST
- && TREE_OVERFLOW (itype))
+ /* The above overflows when size does not fit
+ in index_type.
+ ??? While a size of INT_MAX+1 technically shouldn't
+ cause an overflow (because we subtract 1), handling
+ this case seems like an unnecessary complication. */
+ if (TREE_CODE (size) == INTEGER_CST
+ && !int_fits_type_p (size, index_type))
{
if (name)
error_at (loc, "size of array %qE is too large",