Commit 60a45536 by Richard Guenther Committed by Richard Biener

c-decl.c (grokdeclarator): Instead of looking at TREE_OVERFLOW check if the…

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
parent 539d6b4a
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.
2011-05-03 Richard Sandiford <richard.sandiford@linaro.org> 2011-05-03 Richard Sandiford <richard.sandiford@linaro.org>
* config/arm/neon.md (vec_load_lanes<mode><mode>): New expanders, * config/arm/neon.md (vec_load_lanes<mode><mode>): New expanders,
......
...@@ -5368,15 +5368,13 @@ grokdeclarator (const struct c_declarator *declarator, ...@@ -5368,15 +5368,13 @@ grokdeclarator (const struct c_declarator *declarator,
convert (index_type, convert (index_type,
size_one_node)); size_one_node));
/* If that overflowed, the array is too big. ??? /* The above overflows when size does not fit
While a size of INT_MAX+1 technically shouldn't in index_type.
cause an overflow (because we subtract 1), the ??? While a size of INT_MAX+1 technically shouldn't
overflow is recorded during the conversion to cause an overflow (because we subtract 1), handling
index_type, before the subtraction. Handling this case seems like an unnecessary complication. */
this case seems like an unnecessary if (TREE_CODE (size) == INTEGER_CST
complication. */ && !int_fits_type_p (size, index_type))
if (TREE_CODE (itype) == INTEGER_CST
&& TREE_OVERFLOW (itype))
{ {
if (name) if (name)
error_at (loc, "size of array %qE is too large", error_at (loc, "size of array %qE is too large",
......
2011-05-03 Richard Guenther <rguenther@suse.de>
* gcc.dg/large-size-array-5.c: New testcase.
2011-05-03 Richard Sandiford <richard.sandiford@linaro.org> 2011-05-03 Richard Sandiford <richard.sandiford@linaro.org>
* gcc.dg/vect/vect-strided-u16-i3.c: New test. * gcc.dg/vect/vect-strided-u16-i3.c: New test.
......
/* { dg-do compile } */
/* { dg-options "-Wno-overflow" } */
typedef __SIZE_TYPE__ size_t;
extern char a[((size_t)-1 >> 1) + 1]; /* { dg-error "too large" } */
extern char b[((size_t)-1 >> 1)];
extern int c[(((size_t)-1 >> 1) + 1) / sizeof(int)]; /* { dg-error "too large" } */
extern int d[((size_t)-1 >> 1) / sizeof(int)];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment