This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: boolify {begin/finish}_compound_stmt
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Mark Mitchell <mitchell at codesourcery dot com>
- Date: Mon, 28 Jul 2003 12:05:39 +0100
- Subject: [C++ PATCH]: boolify {begin/finish}_compound_stmt
- Organization: Codesourcery LLC
I've installed this obvious patch to boolify begin_compound_stmt and
remove the parameter from finish_compound_stmt -- it can be
extracted from the compound stmt itself.
booted & tested on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2003-07-28 Nathan Sidwell <nathan@codesourcery.com>
* cp-tree.h (begin_compound_stmt): No scope arg is a bool.
(finish_compound_stmt): Remove no scope arg.
* decl.c (register_dtor_fn): Adjust begin_compound_stmt and
end_compound_stmt calls.
(expand_static_init, begin_destructor_body, begin_function_body,
finish_function_body): Likewise.
* decl2.c (start_objects, finish_objects,
start_static_storage_duration_function,
finish_static_storage_duration_function): Likewise.
* init.c (begin_init_stmts, finish_init_stmts,
construct_virtual_base, build_vec_init): Likewise.
* method.c (do_build_assign_ref, synthesize_method): Likewise.
* parser.c (cp_parser_compound_statement,
cp_parser_implicitly_scoped_statement,
cp_parser_already_scoped_statement): Likewise.
* pt.c (tsubst_expr): Likewise.
* semantics.c (begin_compound_stmt): No scope arg is a bool.
(finish_compound_stmt): Remove no scope arg.
* error.c (dump_expr) <COMPOUND_EXPR case>: A compound expr is
always dyadic.
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.891
diff -c -3 -p -r1.891 cp-tree.h
*** cp/cp-tree.h 26 Jul 2003 19:10:26 -0000 1.891
--- cp/cp-tree.h 28 Jul 2003 10:49:42 -0000
*************** extern void finish_handler_parms
*** 4126,4133 ****
extern void begin_catch_block (tree);
extern void finish_handler (tree);
extern void finish_cleanup (tree, tree);
! extern tree begin_compound_stmt (int);
! extern tree finish_compound_stmt (int, tree);
extern tree finish_asm_stmt (tree, tree, tree, tree, tree);
extern tree finish_label_stmt (tree);
extern void finish_label_decl (tree);
--- 4126,4133 ----
extern void begin_catch_block (tree);
extern void finish_handler (tree);
extern void finish_cleanup (tree, tree);
! extern tree begin_compound_stmt (bool);
! extern tree finish_compound_stmt (tree);
extern tree finish_asm_stmt (tree, tree, tree, tree, tree);
extern tree finish_label_stmt (tree);
extern void finish_label_decl (tree);
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1101
diff -c -3 -p -r1.1101 decl.c
*** cp/decl.c 25 Jul 2003 16:52:46 -0000 1.1101
--- cp/decl.c 28 Jul 2003 10:50:12 -0000
*************** register_dtor_fn (tree decl)
*** 8475,8483 ****
pop_deferring_access_checks ();
/* Create the body of the anonymous function. */
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
finish_expr_stmt (fcall);
! finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
end_cleanup_fn ();
/* Call atexit with the cleanup function. */
--- 8475,8483 ----
pop_deferring_access_checks ();
/* Create the body of the anonymous function. */
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/false);
finish_expr_stmt (fcall);
! finish_compound_stmt (compound_stmt);
end_cleanup_fn ();
/* Call atexit with the cleanup function. */
*************** expand_static_init (tree decl, tree init
*** 8562,8568 ****
/* Begin the conditional initialization. */
if_stmt = begin_if_stmt ();
finish_if_stmt_cond (get_guard_cond (guard), if_stmt);
! then_clause = begin_compound_stmt (/*has_no_scope=*/0);
/* Do the initialization itself. */
assignment = init ? init : NULL_TREE;
--- 8562,8568 ----
/* Begin the conditional initialization. */
if_stmt = begin_if_stmt ();
finish_if_stmt_cond (get_guard_cond (guard), if_stmt);
! then_clause = begin_compound_stmt (/*has_no_scope=*/false);
/* Do the initialization itself. */
assignment = init ? init : NULL_TREE;
*************** expand_static_init (tree decl, tree init
*** 8586,8592 ****
variable. */
register_dtor_fn (decl);
! finish_compound_stmt (/*has_no_scope=*/0, then_clause);
finish_then_clause (if_stmt);
finish_if_stmt ();
}
--- 8586,8592 ----
variable. */
register_dtor_fn (decl);
! finish_compound_stmt (then_clause);
finish_then_clause (if_stmt);
finish_if_stmt ();
}
*************** begin_destructor_body (void)
*** 13840,13853 ****
initialize the vtables.) */
finish_if_stmt_cond (boolean_true_node, if_stmt);
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
/* Make all virtual function table pointers in non-virtual base
classes point to CURRENT_CLASS_TYPE's virtual function
tables. */
initialize_vtbl_ptrs (current_class_ptr);
! finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
finish_then_clause (if_stmt);
finish_if_stmt ();
--- 13840,13853 ----
initialize the vtables.) */
finish_if_stmt_cond (boolean_true_node, if_stmt);
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/false);
/* Make all virtual function table pointers in non-virtual base
classes point to CURRENT_CLASS_TYPE's virtual function
tables. */
initialize_vtbl_ptrs (current_class_ptr);
! finish_compound_stmt (compound_stmt);
finish_then_clause (if_stmt);
finish_if_stmt ();
*************** begin_function_body (void)
*** 13914,13920 ****
operation of dwarfout.c. */
keep_next_level (1);
! stmt = begin_compound_stmt (0);
COMPOUND_STMT_BODY_BLOCK (stmt) = 1;
if (processing_template_decl)
--- 13914,13920 ----
operation of dwarfout.c. */
keep_next_level (1);
! stmt = begin_compound_stmt (/*has_no_scope=*/false);
COMPOUND_STMT_BODY_BLOCK (stmt) = 1;
if (processing_template_decl)
*************** void
*** 13940,13946 ****
finish_function_body (tree compstmt)
{
/* Close the block. */
! finish_compound_stmt (0, compstmt);
if (processing_template_decl)
/* Do nothing now. */;
--- 13940,13946 ----
finish_function_body (tree compstmt)
{
/* Close the block. */
! finish_compound_stmt (compstmt);
if (processing_template_decl)
/* Do nothing now. */;
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.648
diff -c -3 -p -r1.648 decl2.c
*** cp/decl2.c 19 Jul 2003 16:09:46 -0000 1.648
--- cp/decl2.c 28 Jul 2003 10:50:21 -0000
*************** start_objects (int method_type, int init
*** 2025,2031 ****
DECL_GLOBAL_DTOR_P (current_function_decl) = 1;
DECL_LANG_SPECIFIC (current_function_decl)->decl_flags.u2sel = 1;
! body = begin_compound_stmt (/*has_no_scope=*/0);
/* We cannot allow these functions to be elided, even if they do not
have external linkage. And, there's no point in deferring
--- 2025,2031 ----
DECL_GLOBAL_DTOR_P (current_function_decl) = 1;
DECL_LANG_SPECIFIC (current_function_decl)->decl_flags.u2sel = 1;
! body = begin_compound_stmt (/*has_no_scope=*/false);
/* We cannot allow these functions to be elided, even if they do not
have external linkage. And, there's no point in deferring
*************** finish_objects (int method_type, int ini
*** 2046,2052 ****
tree fn;
/* Finish up. */
! finish_compound_stmt (/*has_no_scope=*/0, body);
fn = finish_function (0);
expand_or_defer_fn (fn);
--- 2046,2052 ----
tree fn;
/* Finish up. */
! finish_compound_stmt (body);
fn = finish_function (0);
expand_or_defer_fn (fn);
*************** start_static_storage_duration_function (
*** 2182,2188 ****
SF_PRE_PARSED);
/* Set up the scope of the outermost block in the function. */
! body = begin_compound_stmt (/*has_no_scope=*/0);
/* This function must not be deferred because we are depending on
its compilation to tell us what is TREE_SYMBOL_REFERENCED. */
--- 2182,2188 ----
SF_PRE_PARSED);
/* Set up the scope of the outermost block in the function. */
! body = begin_compound_stmt (/*has_no_scope=*/false);
/* This function must not be deferred because we are depending on
its compilation to tell us what is TREE_SYMBOL_REFERENCED. */
*************** static void
*** 2200,2206 ****
finish_static_storage_duration_function (tree body)
{
/* Close out the function. */
! finish_compound_stmt (/*has_no_scope=*/0, body);
expand_or_defer_fn (finish_function (0));
}
--- 2200,2206 ----
finish_static_storage_duration_function (tree body)
{
/* Close out the function. */
! finish_compound_stmt (body);
expand_or_defer_fn (finish_function (0));
}
Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.226
diff -c -3 -p -r1.226 error.c
*** cp/error.c 25 Jul 2003 09:52:32 -0000 1.226
--- cp/error.c 28 Jul 2003 10:50:25 -0000
*************** dump_expr (tree t, int flags)
*** 1491,1510 ****
case COMPOUND_EXPR:
pp_left_paren (cxx_pp);
! /* Within templates, a COMPOUND_EXPR has only one operand,
! containing a TREE_LIST of the two operands. */
! if (TREE_CODE (TREE_OPERAND (t, 0)) == TREE_LIST)
! {
! if (TREE_OPERAND (t, 1))
! abort();
! dump_expr_list (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! }
! else
! {
! dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! pp_separate_with_comma (cxx_pp);
! dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
! }
pp_right_paren (cxx_pp);
break;
--- 1491,1499 ----
case COMPOUND_EXPR:
pp_left_paren (cxx_pp);
! dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! pp_separate_with_comma (cxx_pp);
! dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
pp_right_paren (cxx_pp);
break;
Index: cp/init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/init.c,v
retrieving revision 1.335
diff -c -3 -p -r1.335 init.c
*** cp/init.c 26 Jul 2003 19:10:26 -0000 1.335
--- cp/init.c 28 Jul 2003 10:50:32 -0000
*************** begin_init_stmts (tree *stmt_expr_p, tre
*** 72,78 ****
bool is_global = !building_stmt_tree ();
*stmt_expr_p = begin_stmt_expr ();
! *compound_stmt_p = begin_compound_stmt (/*has_no_scope=*/1);
return is_global;
}
--- 72,78 ----
bool is_global = !building_stmt_tree ();
*stmt_expr_p = begin_stmt_expr ();
! *compound_stmt_p = begin_compound_stmt (/*has_no_scope=*/true);
return is_global;
}
*************** begin_init_stmts (tree *stmt_expr_p, tre
*** 83,89 ****
static tree
finish_init_stmts (bool is_global, tree stmt_expr, tree compound_stmt)
{
! finish_compound_stmt (/*has_no_scope=*/1, compound_stmt);
stmt_expr = finish_stmt_expr (stmt_expr);
STMT_EXPR_NO_SCOPE (stmt_expr) = true;
--- 83,89 ----
static tree
finish_init_stmts (bool is_global, tree stmt_expr, tree compound_stmt)
{
! finish_compound_stmt (compound_stmt);
stmt_expr = finish_stmt_expr (stmt_expr);
STMT_EXPR_NO_SCOPE (stmt_expr) = true;
*************** construct_virtual_base (tree vbase, tree
*** 842,848 ****
flag = TREE_CHAIN (DECL_ARGUMENTS (current_function_decl));
inner_if_stmt = begin_if_stmt ();
finish_if_stmt_cond (flag, inner_if_stmt);
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/1);
/* Compute the location of the virtual base. If we're
constructing virtual bases, then we must be the most derived
--- 842,848 ----
flag = TREE_CHAIN (DECL_ARGUMENTS (current_function_decl));
inner_if_stmt = begin_if_stmt ();
finish_if_stmt_cond (flag, inner_if_stmt);
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/true);
/* Compute the location of the virtual base. If we're
constructing virtual bases, then we must be the most derived
*************** construct_virtual_base (tree vbase, tree
*** 852,858 ****
expand_aggr_init_1 (vbase, current_class_ref, exp, arguments,
LOOKUP_COMPLAIN);
! finish_compound_stmt (/*has_no_scope=*/1, compound_stmt);
finish_then_clause (inner_if_stmt);
finish_if_stmt ();
--- 852,858 ----
expand_aggr_init_1 (vbase, current_class_ref, exp, arguments,
LOOKUP_COMPLAIN);
! finish_compound_stmt (compound_stmt);
finish_then_clause (inner_if_stmt);
finish_if_stmt ();
*************** build_vec_init (tree base, tree maxindex
*** 2485,2491 ****
&& from_array != 2)
{
try_block = begin_try_block ();
! try_body = begin_compound_stmt (/*has_no_scope=*/1);
}
if (init != NULL_TREE && TREE_CODE (init) == CONSTRUCTOR)
--- 2485,2491 ----
&& from_array != 2)
{
try_block = begin_try_block ();
! try_body = begin_compound_stmt (/*has_no_scope=*/true);
}
if (init != NULL_TREE && TREE_CODE (init) == CONSTRUCTOR)
*************** build_vec_init (tree base, tree maxindex
*** 2564,2570 ****
for_stmt);
/* Otherwise, loop through the elements. */
! for_body = begin_compound_stmt (/*has_no_scope=*/1);
if (from_array)
{
--- 2564,2570 ----
for_stmt);
/* Otherwise, loop through the elements. */
! for_body = begin_compound_stmt (/*has_no_scope=*/true);
if (from_array)
{
*************** build_vec_init (tree base, tree maxindex
*** 2605,2611 ****
if (base2)
finish_expr_stmt (build_unary_op (PREINCREMENT_EXPR, base2, 0));
! finish_compound_stmt (/*has_no_scope=*/1, for_body);
finish_for_stmt (for_stmt);
}
--- 2605,2611 ----
if (base2)
finish_expr_stmt (build_unary_op (PREINCREMENT_EXPR, base2, 0));
! finish_compound_stmt (for_body);
finish_for_stmt (for_stmt);
}
*************** build_vec_init (tree base, tree maxindex
*** 2625,2631 ****
type = strip_array_types (type);
}
! finish_compound_stmt (/*has_no_scope=*/1, try_body);
finish_cleanup_try_block (try_block);
e = build_vec_delete_1 (rval, m,
type,
--- 2625,2631 ----
type = strip_array_types (type);
}
! finish_compound_stmt (try_body);
finish_cleanup_try_block (try_block);
e = build_vec_delete_1 (rval, m,
type,
Index: cp/method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.263
diff -c -3 -p -r1.263 method.c
*** cp/method.c 24 Jul 2003 23:33:25 -0000 1.263
--- cp/method.c 28 Jul 2003 10:50:33 -0000
*************** do_build_assign_ref (tree fndecl)
*** 587,593 ****
tree parm = TREE_CHAIN (DECL_ARGUMENTS (fndecl));
tree compound_stmt;
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
parm = convert_from_reference (parm);
if (TYPE_HAS_TRIVIAL_ASSIGN_REF (current_class_type)
--- 587,593 ----
tree parm = TREE_CHAIN (DECL_ARGUMENTS (fndecl));
tree compound_stmt;
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/false);
parm = convert_from_reference (parm);
if (TYPE_HAS_TRIVIAL_ASSIGN_REF (current_class_type)
*************** do_build_assign_ref (tree fndecl)
*** 680,686 ****
}
}
finish_return_stmt (current_class_ref);
! finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
}
void
--- 680,686 ----
}
}
finish_return_stmt (current_class_ref);
! finish_compound_stmt (compound_stmt);
}
void
*************** synthesize_method (tree fndecl)
*** 744,751 ****
if (need_body)
{
tree compound_stmt;
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
! finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
}
finish_function_body (stmt);
--- 744,751 ----
if (need_body)
{
tree compound_stmt;
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/false);
! finish_compound_stmt (compound_stmt);
}
finish_function_body (stmt);
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.88
diff -c -3 -p -r1.88 parser.c
*** cp/parser.c 23 Jul 2003 13:02:30 -0000 1.88
--- cp/parser.c 28 Jul 2003 10:51:03 -0000
*************** cp_parser_compound_statement (cp_parser
*** 5280,5290 ****
if (!cp_parser_require (parser, CPP_OPEN_BRACE, "`{'"))
return error_mark_node;
/* Begin the compound-statement. */
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
/* Parse an (optional) statement-seq. */
cp_parser_statement_seq_opt (parser);
/* Finish the compound-statement. */
! finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
/* Consume the `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, "`}'");
--- 5280,5290 ----
if (!cp_parser_require (parser, CPP_OPEN_BRACE, "`{'"))
return error_mark_node;
/* Begin the compound-statement. */
! compound_stmt = begin_compound_stmt (/*has_no_scope=*/false);
/* Parse an (optional) statement-seq. */
cp_parser_statement_seq_opt (parser);
/* Finish the compound-statement. */
! finish_compound_stmt (compound_stmt);
/* Consume the `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, "`}'");
*************** cp_parser_implicitly_scoped_statement (c
*** 5762,5772 ****
if (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE))
{
/* Create a compound-statement. */
! statement = begin_compound_stmt (/*has_no_scope=*/0);
/* Parse the dependent-statement. */
cp_parser_statement (parser);
/* Finish the dummy compound-statement. */
! finish_compound_stmt (/*has_no_scope=*/0, statement);
}
/* Otherwise, we simply parse the statement directly. */
else
--- 5762,5772 ----
if (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE))
{
/* Create a compound-statement. */
! statement = begin_compound_stmt (/*has_no_scope=*/false);
/* Parse the dependent-statement. */
cp_parser_statement (parser);
/* Finish the dummy compound-statement. */
! finish_compound_stmt (statement);
}
/* Otherwise, we simply parse the statement directly. */
else
*************** cp_parser_already_scoped_statement (cp_p
*** 5790,5800 ****
tree statement;
/* Create a compound-statement. */
! statement = begin_compound_stmt (/*has_no_scope=*/1);
/* Parse the dependent-statement. */
cp_parser_statement (parser);
/* Finish the dummy compound-statement. */
! finish_compound_stmt (/*has_no_scope=*/1, statement);
}
/* Otherwise, we simply parse the statement directly. */
else
--- 5790,5800 ----
tree statement;
/* Create a compound-statement. */
! statement = begin_compound_stmt (/*has_no_scope=*/true);
/* Parse the dependent-statement. */
cp_parser_statement (parser);
/* Finish the dummy compound-statement. */
! finish_compound_stmt (statement);
}
/* Otherwise, we simply parse the statement directly. */
else
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.738
diff -c -3 -p -r1.738 pt.c
*** cp/pt.c 25 Jul 2003 16:45:34 -0000 1.738
--- cp/pt.c 28 Jul 2003 10:51:27 -0000
*************** tsubst_expr (tree t, tree args, tsubst_f
*** 7730,7736 ****
if (COMPOUND_STMT_BODY_BLOCK (t))
finish_function_body (stmt);
else
! finish_compound_stmt (COMPOUND_STMT_NO_SCOPE (t), stmt);
}
break;
--- 7730,7736 ----
if (COMPOUND_STMT_BODY_BLOCK (t))
finish_function_body (stmt);
else
! finish_compound_stmt (stmt);
}
break;
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.336
diff -c -3 -p -r1.336 semantics.c
*** cp/semantics.c 26 Jul 2003 19:10:26 -0000 1.336
--- cp/semantics.c 28 Jul 2003 10:51:33 -0000
*************** finish_handler (tree handler)
*** 985,996 ****
RECHAIN_STMTS (handler, HANDLER_BODY (handler));
}
! /* Begin a compound-statement. If HAS_NO_SCOPE is nonzero, the
compound-statement does not define a scope. Returns a new
! COMPOUND_STMT if appropriate. */
tree
! begin_compound_stmt (int has_no_scope)
{
tree r;
int is_try = 0;
--- 985,996 ----
RECHAIN_STMTS (handler, 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. */
tree
! begin_compound_stmt (bool has_no_scope)
{
tree r;
int is_try = 0;
*************** begin_compound_stmt (int has_no_scope)
*** 1018,1037 ****
return r;
}
! /* Finish a compound-statement, which may be given by COMPOUND_STMT.
! If HAS_NO_SCOPE is nonzero, the compound statement does not define
! a scope. */
tree
! finish_compound_stmt (int has_no_scope, tree compound_stmt)
{
tree r;
tree t;
! if (!has_no_scope)
! r = do_poplevel ();
! else
r = NULL_TREE;
RECHAIN_STMTS (compound_stmt, COMPOUND_BODY (compound_stmt));
--- 1018,1035 ----
return r;
}
! /* Finish a compound-statement, which is given by COMPOUND_STMT. */
tree
! finish_compound_stmt (tree compound_stmt)
{
tree r;
tree t;
! if (COMPOUND_STMT_NO_SCOPE (compound_stmt))
r = NULL_TREE;
+ else
+ r = do_poplevel ();
RECHAIN_STMTS (compound_stmt, COMPOUND_BODY (compound_stmt));