2014-04-04 Patrick Palka <patrick@parcs.ath.cx>
+ PR c++/44613
+ * semantics.c (add_stmt): Set STATEMENT_LIST_HAS_LABEL.
+ * decl.c (cp_finish_decl): Create a new BIND_EXPR before
+ instantiating a variable-sized type.
+
PR c++/21113
* decl.c (decl_jump_unsafe): Consider variably-modified decls.
after the call to check_initializer so that the DECL_EXPR for a
reference temp is added before the DECL_EXPR for the reference itself. */
if (DECL_FUNCTION_SCOPE_P (decl))
- add_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. */
+ if (VAR_P (decl)
+ && DECL_SIZE (decl)
+ && !TREE_CONSTANT (DECL_SIZE (decl))
+ && STATEMENT_LIST_HAS_LABEL (cur_stmt_list))
+ {
+ tree bind;
+ bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL);
+ TREE_SIDE_EFFECTS (bind) = 1;
+ add_stmt (bind);
+ BIND_EXPR_BODY (bind) = push_stmt_list ();
+ }
+ add_decl_expr (decl);
+ }
/* Let the middle end know about variables and functions -- but not
static data members in uninstantiated class templates. */
STMT_IS_FULL_EXPR_P (t) = stmts_are_full_exprs_p ();
}
+ if (code == LABEL_EXPR || code == CASE_LABEL_EXPR)
+ STATEMENT_LIST_HAS_LABEL (cur_stmt_list) = 1;
+
/* Add T to the statement-tree. Non-side-effect statements need to be
recorded during statement expressions. */
gcc_checking_assert (!stmt_list_stack->is_empty ());