Commit 7bfcb402 by Joseph Myers Committed by Joseph Myers

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
parent 15caa2ab
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> 2007-09-26 Richard Guenther <rguenther@suse.de>
PR tree-optimization/30375 PR tree-optimization/30375
...@@ -7049,6 +7049,16 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) ...@@ -7049,6 +7049,16 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default)
else else
type = c_build_qualified_type (main_type, quals); 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; *ptype = type;
return failure; return failure;
} }
......
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> 2007-09-26 Richard Guenther <rguenther@suse.de>
PR tree-optimization/30375 PR tree-optimization/30375
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
static char * name[] = { static char * name[] = {
[0x80000000] = "bar" [0x80000000] = "bar"
}; };
/* { dg-error "too large" "" { target { ! lp64 } } 6 } */
/* PR c/25309 */
/* { dg-do compile } */
/* { dg-options "" } */
static char * name[] = {
[0x80000000] = "bar"
};
/* { dg-error "too large" "" { target { ! lp64 } } 6 } */
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