From: Duncan Sands Date: Sat, 9 Apr 2011 16:18:01 +0000 (+0200) Subject: Bail out rather than crashing in array_type_nelts if TYPE_MAX_VALUE is null. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b365495ab5fbdf842db5b909b88dea4e2d778a87;p=gcc.git Bail out rather than crashing in array_type_nelts if TYPE_MAX_VALUE is null. From-SVN: r172227 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0ed308626dd..c9976bd9f6f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2011-04-09 Duncan Sands + + * tree.c (array_type_nelts): Bail out if TYPE_MAX_VALUE not set. + 2011-04-08 Eric Botcazou * combine.c (combine_validate_cost): Adjust comments. Set registered diff --git a/gcc/tree.c b/gcc/tree.c index ee47982baf0..cf6fa5068a7 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -2462,6 +2462,10 @@ array_type_nelts (const_tree type) min = TYPE_MIN_VALUE (index_type); max = TYPE_MAX_VALUE (index_type); + /* TYPE_MAX_VALUE may not be set if the array has unknown length. */ + if (!max) + return error_mark_node; + return (integer_zerop (min) ? max : fold_build2 (MINUS_EXPR, TREE_TYPE (max), max, min));