On Thu, 9 Feb 2017, Jakub Jelinek wrote:

> Hi!
> 
> The following testcase ICEs because we've failed to gimplify the array
> bounds.  The array size in bytes e.g. is ((sizetype) (1 / 0) * 4) but
> is TREE_CONSTANT and thus is_gimple_sizepos said that nothing needs to be
> done for it.  In reality, the code actually expects INTEGER_CSTs or
> VAR_DECLs (or NULL).
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux (including Ada) and
> i686-linux (no Ada), ok for trunk?

Ok.

Richard.

> 2017-02-09  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR c/79413
>       * gimplify.h (is_gimple_sizepos): Only test for INTEGER_CST constants,
>       not arbitrary TREE_CONSTANT.
> 
>       * gcc.c-torture/compile/pr79413.c: New test.
> 
> --- gcc/gimplify.h.jj 2017-01-01 12:45:34.000000000 +0100
> +++ gcc/gimplify.h    2017-02-09 12:11:56.008551551 +0100
> @@ -99,7 +99,7 @@ is_gimple_sizepos (tree expr)
>       but that will cause problems if this type is from outside the function.
>       It's OK to have that here.  */
>    return (expr == NULL_TREE
> -       || TREE_CONSTANT (expr)
> +       || TREE_CODE (expr) == INTEGER_CST
>         || TREE_CODE (expr) == VAR_DECL
>         || CONTAINS_PLACEHOLDER_P (expr));
>  }                                        
> --- gcc/testsuite/gcc.c-torture/compile/pr79413.c.jj  2017-02-09 
> 12:16:01.424337042 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr79413.c     2017-02-09 
> 12:15:45.000000000 +0100
> @@ -0,0 +1,13 @@
> +/* PR c/79413 */
> +
> +void
> +foo ()
> +{
> +  int a[1/0];
> +}
> +
> +void
> +bar (void)
> +{
> +  foo ();
> +}
> 
>       Jakub
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)

Reply via email to