]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/27893 (ICE with TREE_CONSTANT VLA sizes inside functions)
authorJoseph Myers <joseph@codesourcery.com>
Sat, 26 Aug 2006 00:16:07 +0000 (01:16 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sat, 26 Aug 2006 00:16:07 +0000 (01:16 +0100)
PR c/27893
* gimplify.c (gimplify_decl_expr, gimplify_init_ctor_preeval):
Treat sizes as variable whenever not INTEGER_CST.

testsuite:
* gcc.c-torture/compile/vla-const-1.c,
gcc.c-torture/compile/vla-const-2.c: New tests.

From-SVN: r116454

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/vla-const-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/vla-const-2.c [new file with mode: 0644]

index b490fa12854cefd89eec0559b2fdbcd95dabcebe..054b2cb14c8077fbafe39993e2312aa04462d1ce 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-25  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/27893
+       * gimplify.c (gimplify_decl_expr, gimplify_init_ctor_preeval):
+       Treat sizes as variable whenever not INTEGER_CST.
+
 2006-08-11  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR rtl-optimization/23454
index 0fa0faa1431376db3214533657702271b69a7a50..b13e96a3c48fe09af26cfbec88bcfe3d2f8822a1 100644 (file)
@@ -992,7 +992,7 @@ gimplify_decl_expr (tree *stmt_p)
     {
       tree init = DECL_INITIAL (decl);
 
-      if (!TREE_CONSTANT (DECL_SIZE (decl)))
+      if (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
        {
          /* This is a variable-sized decl.  Simplify its size and mark it
             for deferred expansion.  Note that mudflap depends on the format
@@ -2398,7 +2398,7 @@ gimplify_init_ctor_preeval (tree *expr_p, tree *pre_p, tree *post_p,
 
   /* If this is of variable size, we have no choice but to assume it doesn't
      overlap since we can't make a temporary for it.  */
-  if (!TREE_CONSTANT (TYPE_SIZE (TREE_TYPE (*expr_p))))
+  if (TREE_CODE (TYPE_SIZE (TREE_TYPE (*expr_p))) != INTEGER_CST)
     return;
 
   /* Otherwise, we must search for overlap ...  */
index 9da2505713787fb502d80b01107fd1ccf68e713c..acda4adc84b34ca20e836e03d8b9ba43dfb821ba 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-25  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/27893
+       * gcc.c-torture/compile/vla-const-1.c,
+       gcc.c-torture/compile/vla-const-2.c: New tests.
+
 2006-08-17  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/28606
diff --git a/gcc/testsuite/gcc.c-torture/compile/vla-const-1.c b/gcc/testsuite/gcc.c-torture/compile/vla-const-1.c
new file mode 100644 (file)
index 0000000..6acc3d8
--- /dev/null
@@ -0,0 +1,5 @@
+/* Test TREE_CONSTANT VLA size: bug 27893.  */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+int a;
+void g(void *);
+void f(void) { int b[(__SIZE_TYPE__)&a]; g(b); }
diff --git a/gcc/testsuite/gcc.c-torture/compile/vla-const-2.c b/gcc/testsuite/gcc.c-torture/compile/vla-const-2.c
new file mode 100644 (file)
index 0000000..913a730
--- /dev/null
@@ -0,0 +1,4 @@
+/* Test TREE_CONSTANT VLA size: bug 27893.  */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+void g(void *);
+void f(void) { int b[1/0]; g(b); }