re PR c/25309 (ICE on initialization of a huge array)

PR c/25309
	* c-common.c (complete_array_type): Diagnose too-large arrays and
	set type to error_mark_node.

testsuite:
	* gcc.dg/large-size-array-2.c: Expect diagnostic for too-large
	array.
	* gcc.dg/large-size-array-4.c: New.  Copy of large-size-array-2.c
	without -O2.

From-SVN: r128811
This commit is contained in:
Joseph Myers 2007-09-26 13:32:27 +01:00 committed by Joseph Myers
parent 15caa2abe9
commit 7bfcb402ea
5 changed files with 32 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2007-09-26 Joseph Myers <joseph@codesourcery.com>
PR c/25309
* c-common.c (complete_array_type): Diagnose too-large arrays and
set type to error_mark_node.
2007-09-26 Richard Guenther <rguenther@suse.de>
PR tree-optimization/30375

View file

@ -7049,6 +7049,16 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default)
else
type = c_build_qualified_type (main_type, quals);
if (COMPLETE_TYPE_P (type)
&& TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST
&& TREE_OVERFLOW (TYPE_SIZE_UNIT (type)))
{
error ("size of array is too large");
/* If we proceed with the array type as it is, we'll eventually
crash in tree_low_cst(). */
type = error_mark_node;
}
*ptype = type;
return failure;
}

View file

@ -1,3 +1,11 @@
2007-09-26 Joseph Myers <joseph@codesourcery.com>
PR c/25309
* gcc.dg/large-size-array-2.c: Expect diagnostic for too-large
array.
* gcc.dg/large-size-array-4.c: New. Copy of large-size-array-2.c
without -O2.
2007-09-26 Richard Guenther <rguenther@suse.de>
PR tree-optimization/30375

View file

@ -4,4 +4,4 @@
static char * name[] = {
[0x80000000] = "bar"
};
/* { dg-error "too large" "" { target { ! lp64 } } 6 } */

View file

@ -0,0 +1,7 @@
/* PR c/25309 */
/* { dg-do compile } */
/* { dg-options "" } */
static char * name[] = {
[0x80000000] = "bar"
};
/* { dg-error "too large" "" { target { ! lp64 } } 6 } */