aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2007-09-26 13:32:27 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2007-09-26 13:32:27 +0100
commit7bfcb402eab7dbcf0108c5b9682a8b409fad4359 (patch)
treef9e25dc097a9407299c63b509b39e45c44233eae /gcc/c-common.c
parent15caa2abe98b8a46bb0225da1d81e585d904d5f2 (diff)
downloadgcc-7bfcb402eab7dbcf0108c5b9682a8b409fad4359.zip
gcc-7bfcb402eab7dbcf0108c5b9682a8b409fad4359.tar.gz
gcc-7bfcb402eab7dbcf0108c5b9682a8b409fad4359.tar.bz2
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
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 8ebc920..bdb8d80 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -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;
}