* c-common.def (COMPOUND_STMT): Remove.
* c-common.c (finish_fname_decls): Don't look through it.
* c-typeck.c (c_tree_expr_nonnegative_p): Likewise.
* c-common.h (COMPOUND_BODY): Remove.
(c_common_stmt_codes): Remove COMPOUND_STMT.
* c-dump.c (c_dump_tree): Likewise.
* c-gimplify.c (c_gimplify_stmt): Likewise.
* c-pretty-print.c (pp_c_statement): Likewise.
* tree.h (DECL_SAVED_TREE): Update commentary.
* doc/c-tree.texi (ASM_EXPR): Rename from ASM_STMT.
(CASE_LABEL_EXPR): Rename from CASE_LABEL.
(GOTO_EXPR): Rename from GOTO_STMT.
(GOTO_FAKE_P): Remove.
(COMPOUND_STMT): Remove.
(HANDLER): Update wrt COMPOUND_STMT.
(STMT_EXPR): Likewise.
(LABEL_EXPR): Rename from LABEL_STMT.
(SCOPE_STMT): Remove.
* objc/objc-act.c (objc_build_try_catch_finally_stmt): Don't look
through COMPOUND_STMT.
cp/
* cp-tree.h (COMPOUND_STMT_TRY_BLOCK, COMPOUND_STMT_BODY_BLOCK): Kill.
(BIND_EXPR_TRY_BLOCK, BIND_EXPR_BODY_BLOCK): New.
* cxx-pretty-print.c (pp_cxx_function_definition): Move handling
of CTOR_INITIALIZER ...
(pp_cxx_statement): ... here.
* decl.c (begin_function_body): Don't set COMPOUND_STMT_BODY_BLOCK.
(finish_function): Use alloc_stmt_list to zap entire function.
* parser.c (cp_parser_compound_statement): Update commentary.
* pt.c (tsubst_expr): Use BIND_EXPR instead of COMPOUND_STMT.
* semantics.c (begin_compound_stmt, finish_compound_stmt): Likewise.
(finish_stmt_expr): Don't look through COMPOUND_STMT.
From-SVN: r83281
+2004-06-16 Richard Henderson <rth@redhat.com>
+
+ * c-common.def (COMPOUND_STMT): Remove.
+ * c-common.c (finish_fname_decls): Don't look through it.
+ * c-typeck.c (c_tree_expr_nonnegative_p): Likewise.
+ * c-common.h (COMPOUND_BODY): Remove.
+ (c_common_stmt_codes): Remove COMPOUND_STMT.
+ * c-dump.c (c_dump_tree): Likewise.
+ * c-gimplify.c (c_gimplify_stmt): Likewise.
+ * c-pretty-print.c (pp_c_statement): Likewise.
+ * tree.h (DECL_SAVED_TREE): Update commentary.
+ * doc/c-tree.texi (ASM_EXPR): Rename from ASM_STMT.
+ (CASE_LABEL_EXPR): Rename from CASE_LABEL.
+ (GOTO_EXPR): Rename from GOTO_STMT.
+ (GOTO_FAKE_P): Remove.
+ (COMPOUND_STMT): Remove.
+ (HANDLER): Update wrt COMPOUND_STMT.
+ (STMT_EXPR): Likewise.
+ (LABEL_EXPR): Rename from LABEL_STMT.
+ (SCOPE_STMT): Remove.
+ * objc/objc-act.c (objc_build_try_catch_finally_stmt): Don't look
+ through COMPOUND_STMT.
+
2004-06-16 Richard Henderson <rth@redhat.com>
* c-common.h (c_begin_if_stmt, c_begin_while_stmt,
{
tree *bodyp = &DECL_SAVED_TREE (current_function_decl);
- if (TREE_CODE (*bodyp) == COMPOUND_STMT)
- bodyp = &COMPOUND_BODY (*bodyp);
if (TREE_CODE (*bodyp) == BIND_EXPR)
bodyp = &BIND_EXPR_BODY (*bodyp);
obtain the expression. */
DEFTREECODE (EXPR_STMT, "expr_stmt", 'e', 1)
-/* Used to represent a brace-enclosed block. The operand is
- COMPOUND_BODY. */
-DEFTREECODE (COMPOUND_STMT, "compound_stmt", 'e', 1)
-
/* Used to represent a local declaration. The operand is
DECL_STMT_DECL. */
DEFTREECODE (DECL_STMT, "decl_stmt", 'e', 1)
#define SWITCH_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2)
-/* COMPOUND_STMT accessor. This gives access to the TREE_LIST of
- statements associated with a compound statement. The result is the
- first statement in the list. Succeeding nodes can be accessed by
- calling TREE_CHAIN on a node in the list. */
-#define COMPOUND_BODY(NODE) TREE_OPERAND (COMPOUND_STMT_CHECK (NODE), 0)
-
/* DECL_STMT accessor. This gives access to the DECL associated with
the given declaration statement. */
#define DECL_STMT_DECL(NODE) TREE_OPERAND (DECL_STMT_CHECK (NODE), 0)
#undef DEFTREECODE
#define c_common_stmt_codes \
- CLEANUP_STMT, EXPR_STMT, COMPOUND_STMT, \
+ CLEANUP_STMT, EXPR_STMT, \
DECL_STMT, IF_STMT, FOR_STMT, \
WHILE_STMT, DO_STMT, RETURN_STMT, \
BREAK_STMT, CONTINUE_STMT, SWITCH_STMT
dump_next_stmt (di, t);
break;
- case COMPOUND_STMT:
- dump_stmt (di, t);
- dump_child ("body", COMPOUND_BODY (t));
- dump_next_stmt (di, t);
- break;
-
case DECL_STMT:
dump_stmt (di, t);
dump_child ("decl", DECL_STMT_DECL (t));
switch (TREE_CODE (stmt))
{
- case COMPOUND_STMT:
- stmt = COMPOUND_BODY (stmt);
- ret = GS_OK;
- break;
-
case FOR_STMT:
ret = gimplify_for_stmt (&stmt, &pre);
break;
}
break;
- /* compound-statement:
- { block-item-list(opt) }
-
- block-item-list:
- block-item
- block-item-list block-item
-
- block-item:
- declaration
- statement */
- case COMPOUND_STMT:
- if (pp_needs_newline (pp))
- pp_newline_and_indent (pp, 0);
- pp_c_left_brace (pp);
- pp_newline_and_indent (pp, 3);
- pp_statement (pp, COMPOUND_BODY (stmt));
- pp_newline_and_indent (pp, -3);
- pp_c_right_brace (pp);
- pp_needs_newline (pp) = true;
- break;
-
/* expression-statement:
expression(opt) ; */
case EXPR_STMT:
c_tree_expr_nonnegative_p (tree t)
{
if (TREE_CODE (t) == STMT_EXPR)
- t = expr_last (COMPOUND_BODY (STMT_EXPR_STMT (t)));
+ t = expr_last (STMT_EXPR_STMT (t));
return tree_expr_nonnegative_p (t);
}
+2004-06-16 Richard Henderson <rth@redhat.com>
+
+ * cp-tree.h (COMPOUND_STMT_TRY_BLOCK, COMPOUND_STMT_BODY_BLOCK): Kill.
+ (BIND_EXPR_TRY_BLOCK, BIND_EXPR_BODY_BLOCK): New.
+ * cxx-pretty-print.c (pp_cxx_function_definition): Move handling
+ of CTOR_INITIALIZER ...
+ (pp_cxx_statement): ... here.
+ * decl.c (begin_function_body): Don't set COMPOUND_STMT_BODY_BLOCK.
+ (finish_function): Use alloc_stmt_list to zap entire function.
+ * parser.c (cp_parser_compound_statement): Update commentary.
+ * pt.c (tsubst_expr): Use BIND_EXPR instead of COMPOUND_STMT.
+ * semantics.c (begin_compound_stmt, finish_compound_stmt): Likewise.
+ (finish_stmt_expr): Don't look through COMPOUND_STMT.
+
2004-06-16 Geoffrey Keating <geoffk@apple.com>
* pt.c (mark_decl_instantiated): Don't call defer_fn.
KOENIG_LOOKUP_P (in CALL_EXPR)
STATEMENT_LIST_NO_SCOPE (in STATEMENT_LIST).
EXPR_STMT_STMT_EXPR_RESULT (in EXPR_STMT)
- COMPOUND_STMT_TRY_BLOCK (in COMPOUND_STMT)
+ BIND_EXPR_TRY_BLOCK (in BIND_EXPR)
1: IDENTIFIER_VIRTUAL_P.
TI_PENDING_TEMPLATE_FLAG.
TEMPLATE_PARMS_FOR_INLINE.
ICS_BAD_FLAG (in _CONV)
FN_TRY_BLOCK_P (in TRY_BLOCK)
IDENTIFIER_CTOR_OR_DTOR_P (in IDENTIFIER_NODE)
- COMPOUND_STMT_BODY_BLOCK (in COMPOUND_STMT)
+ BIND_EXPR_BODY_BLOCK (in BIND_EXPR)
4: BINFO_NEW_VTABLE_MARKED.
TREE_HAS_CONSTRUCTOR (in INDIRECT_REF, SAVE_EXPR, CONSTRUCTOR,
or FIELD_DECL).
#define CLEANUP_P(NODE) TREE_LANG_FLAG_0 (TRY_BLOCK_CHECK (NODE))
-#define COMPOUND_STMT_TRY_BLOCK(NODE) \
- TREE_LANG_FLAG_0 (COMPOUND_STMT_CHECK (NODE))
+#define BIND_EXPR_TRY_BLOCK(NODE) \
+ TREE_LANG_FLAG_0 (BIND_EXPR_CHECK (NODE))
/* Used to mark the block around the member initializers and cleanups. */
-#define COMPOUND_STMT_BODY_BLOCK(NODE) \
- TREE_LANG_FLAG_3 (COMPOUND_STMT_CHECK (NODE))
+#define BIND_EXPR_BODY_BLOCK(NODE) \
+ TREE_LANG_FLAG_3 (BIND_EXPR_CHECK (NODE))
#define STATEMENT_LIST_NO_SCOPE(NODE) \
TREE_LANG_FLAG_0 (STATEMENT_LIST_CHECK (NODE))
pp_needs_newline (pp) = true;
pp->enclosing_scope = DECL_CONTEXT (t);
if (DECL_SAVED_TREE (t))
- {
- tree body = DECL_SAVED_TREE (t);
- if (TREE_CODE (body) == COMPOUND_STMT
- && TREE_CODE (COMPOUND_BODY (body)) == CTOR_INITIALIZER)
- {
- body = COMPOUND_BODY (body);
- pp_cxx_ctor_initializer (pp, body);
- body = TREE_CHAIN (body);
- }
- pp_cxx_statement (pp, body);
- }
+ pp_cxx_statement (pp, DECL_SAVED_TREE (t));
else
{
pp_cxx_semicolon (pp);
{
switch (TREE_CODE (t))
{
+ case CTOR_INITIALIZER:
+ pp_cxx_ctor_initializer (pp, t);
+ break;
+
case USING_STMT:
pp_cxx_identifier (pp, "using");
pp_cxx_identifier (pp, "namespace");
keep_next_level (true);
stmt = begin_compound_stmt (BCS_FN_BODY);
- COMPOUND_STMT_BODY_BLOCK (stmt) = 1;
if (processing_template_decl)
/* Do nothing now. */;
/* Throw away the broken statement tree and extra binding
levels. */
- DECL_SAVED_TREE (fndecl) = build_stmt (COMPOUND_STMT, NULL_TREE);
+ DECL_SAVED_TREE (fndecl) = alloc_stmt_list ();
while (current_binding_level->kind != sk_function_parms)
{
compound-statement:
{ statement-seq [opt] }
- Returns a COMPOUND_STMT representing the statement. */
+ Returns a tree representing the statement. */
static tree
cp_parser_compound_statement (cp_parser *parser, tree in_statement_expr,
}
break;
- case COMPOUND_STMT:
+ case BIND_EXPR:
{
prep_stmt (t);
- if (COMPOUND_STMT_BODY_BLOCK (t))
+ if (BIND_EXPR_BODY_BLOCK (t))
stmt = begin_function_body ();
else
- stmt = begin_compound_stmt (COMPOUND_STMT_TRY_BLOCK (t)
+ stmt = begin_compound_stmt (BIND_EXPR_TRY_BLOCK (t)
? BCS_TRY_BLOCK : 0);
- tsubst_expr (COMPOUND_BODY (t), args, complain, in_decl);
+ tsubst_expr (BIND_EXPR_BODY (t), args, complain, in_decl);
- if (COMPOUND_STMT_BODY_BLOCK (t))
+ if (BIND_EXPR_BODY_BLOCK (t))
finish_function_body (stmt);
else
finish_compound_stmt (stmt);
HANDLER_BODY (handler) = do_poplevel (HANDLER_BODY (handler));
}
-/* Begin a compound-statement. If HAS_NO_SCOPE is true, the
- compound-statement does not define a scope. Returns a new
- COMPOUND_STMT. */
+/* Begin a compound statement. FLAGS contains some bits that control the
+ behaviour and context. If BCS_NO_SCOPE is set, the compound statement
+ does not define a scope. If BCS_FN_BODY is set, this is the outermost
+ block of a function. If BCS_TRY_BLOCK is set, this is the block
+ created on behalf of a TRY statement. Returns a token to be passed to
+ finish_compound_stmt. */
tree
begin_compound_stmt (unsigned int flags)
else
r = do_pushlevel (flags & BCS_TRY_BLOCK ? sk_try : sk_block);
- if (flags & BCS_FN_BODY || processing_template_decl)
+ /* When processing a template, we need to remember where the braces were,
+ so that we can set up identical scopes when instantiating the template
+ later. BIND_EXPR is a handy candidate for this.
+ Note that do_poplevel won't create a BIND_EXPR itself here (and thus
+ result in nested BIND_EXPRs), since we don't build BLOCK nodes when
+ processing templates. */
+ if (processing_template_decl)
{
- r = build (COMPOUND_STMT, NULL_TREE, r);
- COMPOUND_STMT_TRY_BLOCK (r) = (flags & BCS_TRY_BLOCK) != 0;
- COMPOUND_STMT_BODY_BLOCK (r) = (flags & BCS_FN_BODY) != 0;
+ r = build (BIND_EXPR, NULL, NULL, r, NULL);
+ BIND_EXPR_TRY_BLOCK (r) = (flags & BCS_TRY_BLOCK) != 0;
+ BIND_EXPR_BODY_BLOCK (r) = (flags & BCS_FN_BODY) != 0;
TREE_SIDE_EFFECTS (r) = 1;
}
return r;
}
-/* Finish a compound-statement, which is given by COMPOUND_STMT. */
+/* Finish a compound-statement, which is given by STMT. */
void
finish_compound_stmt (tree stmt)
{
- if (TREE_CODE (stmt) == COMPOUND_STMT)
- COMPOUND_BODY (stmt) = do_poplevel (COMPOUND_BODY (stmt));
+ if (TREE_CODE (stmt) == BIND_EXPR)
+ BIND_EXPR_BODY (stmt) = do_poplevel (BIND_EXPR_BODY (stmt));
else if (STATEMENT_LIST_NO_SCOPE (stmt))
stmt = pop_stmt_list (stmt);
else
case BIND_EXPR:
result_stmt_p = &BIND_EXPR_BODY (t);
break;
- case COMPOUND_STMT:
- result_stmt_p = &COMPOUND_BODY (t);
- break;
case TRY_FINALLY_EXPR:
case TRY_CATCH_EXPR:
case CLEANUP_STMT:
@subsection Function Bodies
@cindex function body
@cindex statements
-@tindex ASM_STMT
-@findex ASM_STRING
-@findex ASM_CV_QUAL
-@findex ASM_INPUTS
-@findex ASM_OUTPUTS
-@findex ASM_CLOBBERS
@tindex BREAK_STMT
@tindex CLEANUP_STMT
@findex CLEANUP_DECL
@findex CLEANUP_EXPR
-@tindex COMPOUND_STMT
-@findex COMPOUND_BODY
@tindex CONTINUE_STMT
@tindex DECL_STMT
@findex DECL_STMT_DECL
@findex FOR_COND
@findex FOR_EXPR
@findex FOR_BODY
-@tindex GOTO_STMT
-@findex GOTO_DESTINATION
-@findex GOTO_FAKE_P
@tindex HANDLER
@tindex IF_STMT
@findex IF_COND
@findex THEN_CLAUSE
@findex ELSE_CLAUSE
-@tindex LABEL_STMT
-@tindex LABEL_STMT_LABEL
@tindex RETURN_INIT
@tindex RETURN_STMT
@findex RETURN_EXPR
-@tindex SCOPE_STMT
-@findex SCOPE_BEGIN_P
-@findex SCOPE_END_P
-@findex SCOPE_NULLIFIED_P
@tindex SUBOBJECT
@findex SUBOBJECT_CLEANUP
@tindex SWITCH_STMT
use of the particular value given by @code{DECL_INITIAL}.
The @code{DECL_SAVED_TREE} macro will give the complete body of the
-function. This node will usually be a @code{COMPOUND_STMT} representing
-the outermost block of the function, but it may also be a
-@code{TRY_BLOCK}, a @code{RETURN_INIT}, or any other valid statement.
+function.
@subsubsection Statements
several statements chained together.
@table @code
-@item ASM_STMT
+@item ASM_EXPR
Used to represent an inline assembly statement. For an inline assembly
statement like:
If the assembly statement is declared @code{volatile}, or if the
statement was not an extended assembly statement, and is therefore
implicitly volatile, then the predicate @code{ASM_VOLATILE_P} will hold
-of the @code{ASM_STMT}.
+of the @code{ASM_EXPR}.
@item BREAK_STMT
Used to represent a @code{break} statement. There are no additional
fields.
-@item CASE_LABEL
+@item CASE_LABEL_EXPR
Use to represent a @code{case} label, range of @code{case} labels, or a
@code{default} label. If @code{CASE_LOW} is @code{NULL_TREE}, then this is a
should be run in the reverse order of the order in which the associated
@code{CLEANUP_STMT}s were encountered.
-@item COMPOUND_STMT
-
-Used to represent a brace-enclosed block. The first substatement is
-given by @code{COMPOUND_BODY}. Subsequent substatements are found by
-following the @code{TREE_CHAIN} link from one substatement to the next.
-The @code{COMPOUND_BODY} will be @code{NULL_TREE} if there are no
-substatements.
-
@item CONTINUE_STMT
Used to represent a @code{continue} statement. There are no additional
return statements, while @code{FOR_COND} and @code{FOR_EXPR} return
expressions.
-@item GOTO_STMT
+@item GOTO_EXPR
Used to represent a @code{goto} statement. The @code{GOTO_DESTINATION} will
usually be a @code{LABEL_DECL}. However, if the ``computed goto'' extension
has been used, the @code{GOTO_DESTINATION} will be an arbitrary expression
indicating the destination. This expression will always have pointer type.
-Additionally the @code{GOTO_FAKE_P} flag is set whenever the goto statement
-does not come from source code, but it is generated implicitly by the compiler.
-This is used for branch prediction.
@item HANDLER
is the type of exception that will be caught by this handler; it is
equal (by pointer equality) to @code{NULL} if this handler is for all
types. @code{HANDLER_PARMS} is the @code{DECL_STMT} for the catch
-parameter, and @code{HANDLER_BODY} is the @code{COMPOUND_STMT} for the
-block itself.
+parameter, and @code{HANDLER_BODY} is the code for the block itself.
@item IF_STMT
condition, while the @code{ELSE_CLAUSE} represents the statement given
by the @code{else} condition.
-@item LABEL_STMT
+@item LABEL_EXPR
Used to represent a label. The @code{LABEL_DECL} declared by this
-statement can be obtained with the @code{LABEL_STMT_LABEL} macro. The
+statement can be obtained with the @code{LABEL_EXPR_LABEL} macro. The
@code{IDENTIFIER_NODE} giving the name of the label can be obtained from
the @code{LABEL_DECL} with @code{DECL_NAME}.
return;
@end smallexample
-@item SCOPE_STMT
-
-A scope-statement represents the beginning or end of a scope. If
-@code{SCOPE_BEGIN_P} holds, this statement represents the beginning of a
-scope; if @code{SCOPE_END_P} holds this statement represents the end of
-a scope. On exit from a scope, all cleanups from @code{CLEANUP_STMT}s
-occurring in the scope must be run, in reverse order to the order in
-which they were encountered. If @code{SCOPE_NULLIFIED_P} or
-@code{SCOPE_NO_CLEANUPS_P} holds of the scope, back ends should behave
-as if the @code{SCOPE_STMT} were not present at all.
-
@item SUBOBJECT
In a constructor, these nodes are used to mark the point at which a
In other words, an sequence of statements may occur where a single
expression would normally appear. The @code{STMT_EXPR} node represents
such an expression. The @code{STMT_EXPR_STMT} gives the statement
-contained in the expression; this is always a @code{COMPOUND_STMT}. The
-value of the expression is the value of the last sub-statement in the
-@code{COMPOUND_STMT}. More precisely, the value is the value computed
-by the last @code{EXPR_STMT} in the outermost scope of the
-@code{COMPOUND_STMT}. For example, in:
+contained in the expression. The value of the expression is the value
+of the last sub-statement in the body. More precisely, the value is the
+value computed by the last statement nested inside @code{BIND_EXPR},
+@code{TRY_FINALLY_EXPR}, or @code{TRY_CATCH_EXPR}. For example, in:
@smallexample
(@{ 3; @})
@end smallexample
@smallexample
(@{ if (x) @{ 3; @} @})
@end smallexample
-(represented by a nested @code{COMPOUND_STMT}), there is no value. If
-the @code{STMT_EXPR} does not yield a value, it's type will be
-@code{void}.
+there is no value. If the @code{STMT_EXPR} does not yield a value,
+it's type will be @code{void}.
@item BIND_EXPR
These nodes represent local blocks. The first operand is a list of
/* NB: The operative assumption here is that TRY_FINALLY_EXPR will
deal with all exits from 'try_catch_blk' and route them through
'finally_blk'. */
+ /* ??? This is all crock. What the hell is this trying to do? */
tree outer_blk = objc_build_finally_epilogue ();
- tree prec_stmt = TREE_CHAIN (TREE_CHAIN (COMPOUND_BODY (outer_blk)));
+ tree prec_stmt = TREE_CHAIN (TREE_CHAIN (outer_blk));
tree try_catch_blk = TREE_CHAIN (prec_stmt), try_catch_expr;
tree finally_blk = TREE_CHAIN (try_catch_blk), finally_expr;
tree succ_stmt = TREE_CHAIN (finally_blk);
#define DECL_THREAD_LOCAL(NODE) (VAR_DECL_CHECK (NODE)->decl.thread_local_flag)
/* In a FUNCTION_DECL, the saved representation of the body of the
- entire function. Usually a COMPOUND_STMT, but in C++ this may also
- be a RETURN_INIT, CTOR_INITIALIZER, or TRY_BLOCK. */
+ entire function. */
#define DECL_SAVED_TREE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.saved_tree)
/* List of FUNCTION_DECLs inlined into this function's body. */