aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2004-08-11 21:09:57 -0700
committerRichard Henderson <rth@gcc.gnu.org>2004-08-11 21:09:57 -0700
commit174283a3c26828ee2bf0acd05f6350f439beefcc (patch)
tree0cb6f5299b432c6f23ca205a73d8654219b13413 /gcc/c-decl.c
parent159319544b909404d2ba3997c58a0cbe6541030a (diff)
downloadgcc-174283a3c26828ee2bf0acd05f6350f439beefcc.zip
gcc-174283a3c26828ee2bf0acd05f6350f439beefcc.tar.gz
gcc-174283a3c26828ee2bf0acd05f6350f439beefcc.tar.bz2
c-common.h (STATEMENT_LIST_HAS_LABEL): New.
* c-common.h (STATEMENT_LIST_HAS_LABEL): New. * c-semantics.c (add_stmt): Set it. * c-decl.c (finish_decl): Use it to create a new BIND_EXPR before instantiating a variable sized type. From-SVN: r85849
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index c03c126..82e42f0 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -3061,7 +3061,24 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
}
if (TREE_CODE (decl) != FUNCTION_DECL)
- add_stmt (build_stmt (DECL_EXPR, decl));
+ {
+ /* If we're building a variable sized type, and we might be
+ reachable other than via the top of the current binding
+ level, then create a new BIND_EXPR so that we deallocate
+ the object at the right time. */
+ /* Note that DECL_SIZE can be null due to errors. */
+ if (DECL_SIZE (decl)
+ && !TREE_CONSTANT (DECL_SIZE (decl))
+ && STATEMENT_LIST_HAS_LABEL (cur_stmt_list))
+ {
+ tree bind;
+ bind = build (BIND_EXPR, void_type_node, NULL, NULL, NULL);
+ TREE_SIDE_EFFECTS (bind) = 1;
+ add_stmt (bind);
+ BIND_EXPR_BODY (bind) = push_stmt_list ();
+ }
+ add_stmt (build_stmt (DECL_EXPR, decl));
+ }
}