On Sat, Apr 9, 2011 at 1:22 PM, Duncan Sands <baldr...@free.fr> wrote:
> I recently changed the dragonegg plugin to use array_type_nelts, and just
> got
> sent a Fortran testcase that shows that array_type_nelts can crash on array
> types coming from Fortran.  The array type in question has TYPE_DOMAIN set,
> with TYPE_MIN_VALUE equal to 1 (because the array is indexed from 1) but no
> TYPE_MAX_VALUE (because the array length is not known).  Here's a patch that
> fixes array_type_nelts.  Unfortunately I don't have a testcase that shows
> the
> issue without the use of the dragonegg plugin.
>
> Tested by bootstrapping mainline and running the testsuite with gcc-4.5.  OK
> to
> apply on mainline and the 4.5 and 4.6 branches?

Ok.

Thanks,
Richard.

> Ciao, Duncan.
>
> Index: gcc/tree.c
> ===================================================================
> --- gcc/tree.c  (revision 172166)
> +++ gcc/tree.c  (working copy)
> @@ -2462,6 +2462,10 @@
>   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));
> Index: gcc/ChangeLog
> ===================================================================
> --- gcc/ChangeLog       (revision 172166)
> +++ gcc/ChangeLog       (working copy)
> @@ -1,3 +1,7 @@
> +2011-04-08  Duncan Sands  <baldr...@free.fr>
> +
> +       * tree.c (array_type_nelts): Bail out if TYPE_MAX_VALUE not set.
> +
>  2011-04-08  Anatoly Sokolov  <ae...@post.ru>
>
>        * doc/tm.texi.in (ASM_OUTPUT_BSS): Remove documentation.
>

Reply via email to