mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-28 20:01:18 +08:00
c-common.h (add_decl_stmt): Move to cp-tree.h.
* c-common.h (add_decl_stmt): Move to cp-tree.h. * c-decl.c (finish_decl): Don't use add_decl_stmt. * c-parse.in: Likewise. * c-gimplify.c (gimplify_expr_stmt): Don't build CLEANUP_POINT_EXPR. (gimplify_c_loop, gimplify_return_stmt, gimplify_decl_stmt): Likewise. * c-semantics.c (add_decl_stmt): Move to cp/semantics.c. cp/ * cp-tree.h (add_decl_stmt): Declare. * pt.c (tsubst_copy): Abort for CLEANUP_POINT_EXPR. * semantics.c (maybe_cleanup_point_expr): New. (add_decl_stmt, finish_expr_stmt, finish_return_stmt, finish_for_expr, finish_switch_cond): Use it. (finalize_nrv_r): Don't build an EXPR_STMT. Don't frob TREE_CHAIN. From-SVN: r83409
This commit is contained in:
parent
aa33d72501
commit
543a0daa84
@ -1,3 +1,12 @@
|
||||
2004-06-20 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* c-common.h (add_decl_stmt): Move to cp-tree.h.
|
||||
* c-decl.c (finish_decl): Don't use add_decl_stmt.
|
||||
* c-parse.in: Likewise.
|
||||
* c-gimplify.c (gimplify_expr_stmt): Don't build CLEANUP_POINT_EXPR.
|
||||
(gimplify_c_loop, gimplify_return_stmt, gimplify_decl_stmt): Likewise.
|
||||
* c-semantics.c (add_decl_stmt): Move to cp/semantics.c.
|
||||
|
||||
2004-06-20 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* c-common.def (IF_STMT, CLEANUP_STMT): Move to cp-tree.def.
|
||||
|
@ -294,7 +294,6 @@ extern tree push_stmt_list (void);
|
||||
extern tree re_push_stmt_list (tree);
|
||||
extern tree pop_stmt_list (tree);
|
||||
extern tree add_stmt (tree);
|
||||
extern void add_decl_stmt (tree);
|
||||
extern void push_cleanup (tree, tree, bool);
|
||||
|
||||
extern tree walk_stmt_tree (tree *, walk_tree_fn, void *);
|
||||
|
@ -2940,7 +2940,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
|
||||
}
|
||||
|
||||
if (TREE_CODE (decl) != FUNCTION_DECL)
|
||||
add_decl_stmt (decl);
|
||||
add_stmt (build_stmt (DECL_STMT, decl));
|
||||
}
|
||||
|
||||
if (!DECL_FILE_SCOPE_P (decl))
|
||||
@ -2967,7 +2967,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
|
||||
{
|
||||
if (!DECL_FILE_SCOPE_P (decl)
|
||||
&& variably_modified_type_p (TREE_TYPE (decl)))
|
||||
add_decl_stmt (decl);
|
||||
add_stmt (build_stmt (DECL_STMT, decl));
|
||||
|
||||
rest_of_decl_compilation (decl, NULL, DECL_FILE_SCOPE_P (decl), 0);
|
||||
}
|
||||
|
@ -249,8 +249,6 @@ gimplify_expr_stmt (tree *stmt_p)
|
||||
|
||||
if (stmt == NULL_TREE)
|
||||
stmt = build_empty_stmt ();
|
||||
else if (stmts_are_full_exprs_p ())
|
||||
stmt = build1 (CLEANUP_POINT_EXPR, void_type_node, stmt);
|
||||
|
||||
*stmt_p = stmt;
|
||||
|
||||
@ -383,8 +381,6 @@ gimplify_c_loop (tree cond, tree body, tree incr, bool cond_is_first)
|
||||
cont_block = begin_bc_block (bc_continue);
|
||||
|
||||
gimplify_stmt (&body);
|
||||
if (incr && stmts_are_full_exprs_p ())
|
||||
incr = fold (build1 (CLEANUP_POINT_EXPR, void_type_node, incr));
|
||||
gimplify_stmt (&incr);
|
||||
|
||||
body = finish_bc_block (cont_block, body);
|
||||
@ -483,8 +479,6 @@ gimplify_return_stmt (tree *stmt_p)
|
||||
{
|
||||
tree expr = RETURN_STMT_EXPR (*stmt_p);
|
||||
expr = build1 (RETURN_EXPR, void_type_node, expr);
|
||||
if (stmts_are_full_exprs_p ())
|
||||
expr = build1 (CLEANUP_POINT_EXPR, void_type_node, expr);
|
||||
*stmt_p = expr;
|
||||
return GS_OK;
|
||||
}
|
||||
@ -553,8 +547,6 @@ gimplify_decl_stmt (tree *stmt_p)
|
||||
|
||||
DECL_INITIAL (decl) = NULL_TREE;
|
||||
init = build (MODIFY_EXPR, void_type_node, decl, init);
|
||||
if (stmts_are_full_exprs_p ())
|
||||
init = build1 (CLEANUP_POINT_EXPR, void_type_node, init);
|
||||
append_to_compound_expr (init, &pre);
|
||||
}
|
||||
else
|
||||
|
@ -1540,7 +1540,7 @@ nested_function:
|
||||
add_stmt ($6);
|
||||
finish_function ();
|
||||
pop_function_context ();
|
||||
add_decl_stmt (decl); }
|
||||
add_stmt (build_stmt (DECL_STMT, decl)); }
|
||||
;
|
||||
|
||||
notype_nested_function:
|
||||
@ -1570,7 +1570,7 @@ notype_nested_function:
|
||||
add_stmt ($6);
|
||||
finish_function ();
|
||||
pop_function_context ();
|
||||
add_decl_stmt (decl); }
|
||||
add_stmt (build_stmt (DECL_STMT, decl)); }
|
||||
;
|
||||
|
||||
/* Any kind of declarator (thus, all declarators allowed
|
||||
@ -2019,7 +2019,7 @@ label_decl:
|
||||
{
|
||||
tree label = declare_label (TREE_VALUE (link));
|
||||
C_DECLARED_LABEL_FLAG (label) = 1;
|
||||
add_decl_stmt (label);
|
||||
add_stmt (build_stmt (DECL_STMT, label));
|
||||
}
|
||||
}
|
||||
;
|
||||
|
@ -145,19 +145,6 @@ add_stmt (tree t)
|
||||
return t;
|
||||
}
|
||||
|
||||
/* Create a declaration statement for the declaration given by the
|
||||
DECL. */
|
||||
|
||||
void
|
||||
add_decl_stmt (tree decl)
|
||||
{
|
||||
tree decl_stmt;
|
||||
|
||||
/* We need the type to last until instantiation time. */
|
||||
decl_stmt = build_stmt (DECL_STMT, decl);
|
||||
add_stmt (decl_stmt);
|
||||
}
|
||||
|
||||
/* Build a generic statement based on the given type of node and
|
||||
arguments. Similar to `build_nt', except that we set
|
||||
EXPR_LOCUS to be the current source location. */
|
||||
|
@ -1,3 +1,12 @@
|
||||
2004-06-20 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* cp-tree.h (add_decl_stmt): Declare.
|
||||
* pt.c (tsubst_copy): Abort for CLEANUP_POINT_EXPR.
|
||||
* semantics.c (maybe_cleanup_point_expr): New.
|
||||
(add_decl_stmt, finish_expr_stmt, finish_return_stmt,
|
||||
finish_for_expr, finish_switch_cond): Use it.
|
||||
(finalize_nrv_r): Don't build an EXPR_STMT. Don't frob TREE_CHAIN.
|
||||
|
||||
2004-06-20 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* cp-tree.def (CLEANUP_STMT, IF_STMT): Move from c-common.def.
|
||||
|
@ -4028,6 +4028,7 @@ extern void pop_to_parent_deferring_access_checks (void);
|
||||
extern void perform_deferred_access_checks (void);
|
||||
extern void perform_or_defer_access_check (tree, tree);
|
||||
extern void init_cp_semantics (void);
|
||||
extern void add_decl_stmt (tree);
|
||||
extern tree finish_expr_stmt (tree);
|
||||
extern tree begin_if_stmt (void);
|
||||
extern void finish_if_stmt_cond (tree, tree);
|
||||
|
@ -7726,6 +7726,12 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
|
||||
in_decl),
|
||||
tsubst (TREE_TYPE (t), args, complain, in_decl));
|
||||
|
||||
case CLEANUP_POINT_EXPR:
|
||||
/* We shouldn't have built any of these during initial template
|
||||
generation. Instead, they should be built during instantiation
|
||||
in response to the saved STMT_IS_FULL_EXPR_P setting. */
|
||||
abort ();
|
||||
|
||||
default:
|
||||
return t;
|
||||
}
|
||||
|
@ -304,6 +304,27 @@ current_stmt_tree (void)
|
||||
: &scope_chain->x_stmt_tree);
|
||||
}
|
||||
|
||||
/* If statements are full expressions, wrap STMT in a CLEANUP_POINT_EXPR. */
|
||||
|
||||
static tree
|
||||
maybe_cleanup_point_expr (tree expr)
|
||||
{
|
||||
if (!processing_template_decl && stmts_are_full_exprs_p ())
|
||||
expr = fold (build1 (CLEANUP_POINT_EXPR, TREE_TYPE (expr), expr));
|
||||
return expr;
|
||||
}
|
||||
|
||||
/* Create a declaration statement for the declaration given by the DECL. */
|
||||
|
||||
void
|
||||
add_decl_stmt (tree decl)
|
||||
{
|
||||
tree r = build_stmt (DECL_STMT, decl);
|
||||
if (DECL_INITIAL (decl))
|
||||
r = maybe_cleanup_point_expr (r);
|
||||
add_stmt (r);
|
||||
}
|
||||
|
||||
/* Nonzero if TYPE is an anonymous union or struct type. We have to use a
|
||||
flag for this because "A union for which objects or pointers are
|
||||
declared is not an anonymous union" [class.union]. */
|
||||
@ -478,8 +499,13 @@ finish_expr_stmt (tree expr)
|
||||
|
||||
/* Simplification of inner statement expressions, compound exprs,
|
||||
etc can result in the us already having an EXPR_STMT. */
|
||||
if (TREE_CODE (expr) != EXPR_STMT)
|
||||
expr = build_stmt (EXPR_STMT, expr);
|
||||
if (TREE_CODE (expr) != CLEANUP_POINT_EXPR)
|
||||
{
|
||||
if (TREE_CODE (expr) != EXPR_STMT)
|
||||
expr = build_stmt (EXPR_STMT, expr);
|
||||
expr = maybe_cleanup_point_expr (expr);
|
||||
}
|
||||
|
||||
r = add_stmt (expr);
|
||||
}
|
||||
|
||||
@ -636,7 +662,10 @@ finish_return_stmt (tree expr)
|
||||
return finish_goto_stmt (dtor_label);
|
||||
}
|
||||
}
|
||||
r = add_stmt (build_stmt (RETURN_STMT, expr));
|
||||
|
||||
r = build_stmt (RETURN_STMT, expr);
|
||||
r = maybe_cleanup_point_expr (r);
|
||||
r = add_stmt (r);
|
||||
finish_stmt ();
|
||||
|
||||
return r;
|
||||
@ -690,13 +719,16 @@ finish_for_cond (tree cond, tree for_stmt)
|
||||
void
|
||||
finish_for_expr (tree expr, tree for_stmt)
|
||||
{
|
||||
if (!expr)
|
||||
return;
|
||||
/* If EXPR is an overloaded function, issue an error; there is no
|
||||
context available to use to perform overload resolution. */
|
||||
if (expr && type_unknown_p (expr))
|
||||
if (type_unknown_p (expr))
|
||||
{
|
||||
cxx_incomplete_type_error (expr, TREE_TYPE (expr));
|
||||
expr = error_mark_node;
|
||||
}
|
||||
expr = maybe_cleanup_point_expr (expr);
|
||||
FOR_EXPR (for_stmt) = expr;
|
||||
}
|
||||
|
||||
@ -777,7 +809,7 @@ finish_switch_cond (tree cond, tree switch_stmt)
|
||||
|
||||
Integral promotions are performed. */
|
||||
cond = perform_integral_promotions (cond);
|
||||
cond = fold (build1 (CLEANUP_POINT_EXPR, TREE_TYPE (cond), cond));
|
||||
cond = maybe_cleanup_point_expr (cond);
|
||||
}
|
||||
|
||||
if (cond != error_mark_node)
|
||||
@ -1499,8 +1531,7 @@ finish_stmt_expr (tree stmt_expr, bool has_no_scope)
|
||||
init = TREE_OPERAND (target_expr, 1);
|
||||
type = TREE_TYPE (init);
|
||||
|
||||
if (stmts_are_full_exprs_p ())
|
||||
init = fold (build1 (CLEANUP_POINT_EXPR, type, init));
|
||||
init = maybe_cleanup_point_expr (init);
|
||||
*result_stmt_p = init;
|
||||
|
||||
if (VOID_TYPE_P (type))
|
||||
@ -2995,10 +3026,8 @@ finalize_nrv_r (tree* tp, int* walk_subtrees, void* data)
|
||||
DECL_INITIAL (dp->var) = error_mark_node;
|
||||
}
|
||||
else
|
||||
init = NULL_TREE;
|
||||
init = build_stmt (EXPR_STMT, init);
|
||||
init = build_empty_stmt ();
|
||||
SET_EXPR_LOCUS (init, EXPR_LOCUS (*tp));
|
||||
TREE_CHAIN (init) = TREE_CHAIN (*tp);
|
||||
*tp = init;
|
||||
}
|
||||
/* And replace all uses of the NRV with the RESULT_DECL. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user