]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/19771 (VLA deallocation)
authorJoseph Myers <joseph@codesourcery.com>
Sun, 19 Apr 2009 20:19:54 +0000 (21:19 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sun, 19 Apr 2009 20:19:54 +0000 (21:19 +0100)
PR c/19771
* c-semantics.c (pop_stmt_list): Propagate
STATEMENT_LIST_HAS_LABEL to parent statement list.

testsuite:
* gcc.c-torture/execute/vla-dealloc-1.c: New test.

From-SVN: r146358

gcc/ChangeLog
gcc/c-semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/vla-dealloc-1.c [new file with mode: 0644]

index a7dcc8ed6db72b9012aa89d4b7f89c5a69af1c41..01488bf8bf9bdb30ad14b5577ffcf8b685205732 100644 (file)
@@ -1,3 +1,9 @@
+2009-04-19  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/19771
+       * c-semantics.c (pop_stmt_list): Propagate
+       STATEMENT_LIST_HAS_LABEL to parent statement list.
+
 2009-04-19  Adam Nemet  <anemet@caviumnetworks.com>
 
        * config/mips/mips.h (mips_tune_attr): New macro.
index 3c7b241b999b75edf74704065193993708d6c270..b6c3a27c5ab0b6065193241434a25525bb89d42e 100644 (file)
@@ -70,6 +70,8 @@ pop_stmt_list (tree t)
     {
       chain = TREE_CHAIN (u);
       TREE_CHAIN (u) = NULL_TREE;
+      if (chain)
+       STATEMENT_LIST_HAS_LABEL (chain) |= STATEMENT_LIST_HAS_LABEL (u);
       if (t == u)
        break;
       u = chain;
index fd41b3225e4ef8d1978d2583bb37fa0e2b1b5f07..a3e266be90a7e4ee1b82cd18d4025324dbb349a1 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-19  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/19771
+       * gcc.c-torture/execute/vla-dealloc-1.c: New test.
+
 2009-04-19  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/38243
diff --git a/gcc/testsuite/gcc.c-torture/execute/vla-dealloc-1.c b/gcc/testsuite/gcc.c-torture/execute/vla-dealloc-1.c
new file mode 100644 (file)
index 0000000..f2291ad
--- /dev/null
@@ -0,0 +1,22 @@
+/* VLAs should be deallocated on a jump to before their definition,
+   including a jump to a label in an inner scope.  PR 19771.  */
+
+void *volatile p;
+
+int
+main (void)
+{
+  int n = 0;
+  if (0)
+    {
+    lab:;
+    }
+  int x[n % 1000 + 1];
+  x[0] = 1;
+  x[n % 1000] = 2;
+  p = x;
+  n++;
+  if (n < 1000000)
+    goto lab;
+  return 0;
+}