* c-common.c (statement_code_p): Handle CLEANUP_STMT.
* c-common.def (CLEANUP_STMT): New tree node.
* c-common.h (CLEANUP_DECL): New macro.
(CLEANUP_EXPR): Likewise.
* c-semantics.c (expand_stmt): Handle CLEANUP_STMT.
* tree-dump.c (dequeue_and_dump): Handle CLEANUP_STMT.
* tree-inline.c (initialize_inlined_parameters): Clean up
new local variables.
* cp-tree.h (CLEANUP_DECL): Remove.
(CLEANUP_EXPR): Likewise.
* decl.c (destroy_local_var): Simplify.
(maybe_build_cleanup): Tidy.
* dump.c (cp_dump_tree): Remove handling of CLEANUP_STMT.
* semantics.c (cp_expand_stmt): Likewise.
* cp/tree.c (cp_statement_code_p): Likewise.
* g++.dg/opt/dtor1.C: New test.
From-SVN: r50830
+2002-03-15 Mark Mitchell <mark@codesourcery.com>
+
+ * c-common.c (statement_code_p): Handle CLEANUP_STMT.
+ * c-common.def (CLEANUP_STMT): New tree node.
+ * c-common.h (CLEANUP_DECL): New macro.
+ (CLEANUP_EXPR): Likewise.
+ * c-semantics.c (expand_stmt): Handle CLEANUP_STMT.
+ * expr.c (expand_expr): Tidy.
+ * tree-dump.c (dequeue_and_dump): Handle CLEANUP_STMT.
+ * tree-inline.c (initialize_inlined_parameters): Clean up
+ new local variables.
+
2002-03-15 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/4128
{
switch (code)
{
+ case CLEANUP_STMT:
case EXPR_STMT:
case COMPOUND_STMT:
case DECL_STMT:
the compound literal. */
DEFTREECODE (COMPOUND_LITERAL_EXPR, "compound_literal_expr", 'e', 1)
+/* A CLEANUP_STMT marks the point at which a declaration is fully
+ constructed. If, after this point, the CLEANUP_DECL goes out of
+ scope, the CLEANUP_EXPR must be run. */
+DEFTREECODE (CLEANUP_STMT, "cleanup_stmt", 'e', 2)
+
/*
Local variables:
mode:c
#define ASM_VOLATILE_P(NODE) \
(ASM_CV_QUAL (ASM_STMT_CHECK (NODE)) != NULL_TREE)
+/* The VAR_DECL to clean up in a CLEANUP_STMT. */
+#define CLEANUP_DECL(NODE) \
+ TREE_OPERAND (CLEANUP_STMT_CHECK (NODE), 0)
+/* The cleanup to run in a CLEANUP_STMT. */
+#define CLEANUP_EXPR(NODE) \
+ TREE_OPERAND (CLEANUP_STMT_CHECK (NODE), 1)
+
/* The filename we are changing to as of this FILE_STMT. */
#define FILE_STMT_FILENAME_NODE(NODE) \
(TREE_OPERAND (FILE_STMT_CHECK (NODE), 0))
genrtl_scope_stmt (t);
break;
+ case CLEANUP_STMT:
+ genrtl_decl_cleanup (CLEANUP_DECL (t), CLEANUP_EXPR (t));
+ break;
+
default:
if (lang_expand_stmt)
(*lang_expand_stmt) (t);
+2002-03-15 Mark Mitchell <mark@codesourcery.com>
+
+ * cp-tree.h (CLEANUP_DECL): Remove.
+ (CLEANUP_EXPR): Likewise.
+ * decl.c (destroy_local_var): Simplify.
+ (maybe_build_cleanup): Tidy.
+ * dump.c (cp_dump_tree): Remove handling of CLEANUP_STMT.
+ * semantics.c (cp_expand_stmt): Likewise.
+ * cp/tree.c (cp_statement_code_p): Likewise.
+
2002-03-15 Jason Merrill <jason@redhat.com>
PR c++/5857
the cleanups associated with any SUBOBJECT_CLEANUPS need no longer
be run. */
DEFTREECODE (CTOR_STMT, "ctor_stmt", 'e', 0)
-/* A CLEANUP_STMT marks the point at which a declaration is fully
- constructed. If, after this point, the CLEANUP_DECL goes out of
- scope, the CLEANUP_EXPR must be run. */
-DEFTREECODE (CLEANUP_STMT, "cleanup_stmt", 'e', 2)
/* CTOR_INITIALIZER is a placeholder in template code for a call to
setup_vtbl_pointer (and appears in all functions, not just ctors). */
DEFTREECODE (CTOR_INITIALIZER, "ctor_initializer", 'e', 2)
set_namespace_binding ((NODE), current_namespace, (VAL))
#define CLEANUP_P(NODE) TREE_LANG_FLAG_0 (TRY_BLOCK_CHECK (NODE))
-#define CLEANUP_DECL(NODE) TREE_OPERAND (CLEANUP_STMT_CHECK (NODE), 0)
-#define CLEANUP_EXPR(NODE) TREE_OPERAND (CLEANUP_STMT_CHECK (NODE), 1)
/* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
sense of `same'. */
cleanup = maybe_build_cleanup (decl);
/* Record the cleanup required for this declaration. */
- if (DECL_SIZE (decl) && TREE_TYPE (decl) != error_mark_node
- && cleanup)
+ if (DECL_SIZE (decl) && cleanup)
finish_decl_cleanup (decl, cleanup);
}
return rval;
}
- return 0;
+ return NULL_TREE;
}
\f
/* When a stmt has been parsed, this function is called. */
/* Tree-dumping functionality for intermediate representation.
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>
This file is part of GNU CC.
dump_child ("decl", TREE_OPERAND (t, 2));
break;
- case CLEANUP_STMT:
- dump_stmt (di, t);
- dump_child ("decl", CLEANUP_DECL (t));
- dump_child ("expr", CLEANUP_EXPR (t));
- dump_next_stmt (di, t);
- break;
-
case CTOR_STMT:
dump_stmt (di, t);
if (CTOR_BEGIN_P (t))
{
switch (TREE_CODE (t))
{
- case CLEANUP_STMT:
- genrtl_decl_cleanup (CLEANUP_DECL (t), CLEANUP_EXPR (t));
- break;
-
case CTOR_STMT:
genrtl_ctor_stmt (t);
break;
switch (code)
{
case SUBOBJECT:
- case CLEANUP_STMT:
case CTOR_STMT:
case CTOR_INITIALIZER:
case RETURN_INIT:
+2002-03-15 Mark Mitchell <mark@codesourcery.com>
+
+ * g++.dg/opt/dtor1.C: New test.
+
2002-03-15 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/compile/20020315-1.c: New test.
--- /dev/null
+// { dg-do run }
+// { dg-options "-O2" }
+
+int i;
+
+struct S {
+ S ();
+ S (const S&);
+ ~S ();
+};
+
+S::S () { ++i; }
+S::S (const S&) { ++i; }
+S::~S () { --i; }
+
+inline void f (S) {
+}
+
+int main () {
+ {
+ S s;
+ f (s);
+ }
+
+ return i;
+}
+
dump_next_stmt (di, t);
break;
+ case CLEANUP_STMT:
+ dump_stmt (di, t);
+ dump_child ("decl", CLEANUP_DECL (t));
+ dump_child ("expr", CLEANUP_EXPR (t));
+ dump_next_stmt (di, t);
+ break;
+
case COMPOUND_STMT:
dump_stmt (di, t);
dump_child ("body", COMPOUND_BODY (t));
tree init_stmt;
tree var;
tree value;
+ tree cleanup;
/* Find the initializer. */
value = a ? TREE_VALUE (a) : NULL_TREE;
TREE_CHAIN (init_stmt) = init_stmts;
init_stmts = init_stmt;
}
+
+ /* See if we need to clean up the declaration. */
+ cleanup = maybe_build_cleanup (var);
+ if (cleanup)
+ {
+ tree cleanup_stmt;
+ /* Build the cleanup statement. */
+ cleanup_stmt = build_stmt (CLEANUP_STMT, var, cleanup);
+ /* Add it to the *front* of the list; the list will be
+ reversed below. */
+ TREE_CHAIN (cleanup_stmt) = init_stmts;
+ init_stmts = cleanup_stmt;
+ }
}
/* Evaluate trailing arguments. */
for (; a; a = TREE_CHAIN (a))
{
tree init_stmt;
- tree value;
-
- /* Find the initializer. */
- value = a ? TREE_VALUE (a) : NULL_TREE;
+ tree value = TREE_VALUE (a);
if (! value || ! TREE_SIDE_EFFECTS (value))
continue;