diff mbox

Gimplify even TREE_CONSTANT VLA bounds unless they are INTEGER_CST (PR c/79413)

Message ID 20170209141250.GK1849@tucnak
State New
Headers show

Commit Message

Jakub Jelinek Feb. 9, 2017, 2:12 p.m. UTC
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.


	Jakub

Comments

Richard Biener Feb. 9, 2017, 2:19 p.m. UTC | #1
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
> 
>
diff mbox

Patch

--- 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 ();
+}