* [PATCH] Gimplify even TREE_CONSTANT VLA bounds unless they are INTEGER_CST (PR c/79413)
@ 2017-02-09 14:12 Jakub Jelinek
2017-02-09 14:19 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2017-02-09 14:12 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches, Eric Botcazou
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?
2017-02-09 Jakub Jelinek <jakub@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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Gimplify even TREE_CONSTANT VLA bounds unless they are INTEGER_CST (PR c/79413)
2017-02-09 14:12 [PATCH] Gimplify even TREE_CONSTANT VLA bounds unless they are INTEGER_CST (PR c/79413) Jakub Jelinek
@ 2017-02-09 14:19 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-02-09 14:19 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, Eric Botcazou
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 <jakub@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 <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-02-09 14:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-09 14:12 [PATCH] Gimplify even TREE_CONSTANT VLA bounds unless they are INTEGER_CST (PR c/79413) Jakub Jelinek
2017-02-09 14:19 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).