From b58564754b8f157067e661a00c83c8fd9c75dc54 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 22 Jan 2002 09:42:09 -0500 Subject: [PATCH] parse.y (function_body): Suppress the block for the outermost curly braces. * parse.y (function_body): Suppress the block for the outermost curly braces. * decl.c (pushdecl): Don't try to skip it. (begin_function_body): Keep the block we create, not the next one. * init.c (emit_base_init): Don't mess with keep_next_level. From-SVN: r49076 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 16 ++++++++-------- gcc/cp/init.c | 8 -------- gcc/cp/parse.y | 11 +++++++++-- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 18f5038fcab..7c88cace7fd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2002-01-22 Jason Merrill + * parse.y (function_body): Suppress the block for the outermost + curly braces. + * decl.c (pushdecl): Don't try to skip it. + (begin_function_body): Keep the block we create, not the next one. + * init.c (emit_base_init): Don't mess with keep_next_level. + * class.c (build_base_path): Tweak formatting. 2002-01-19 Nathan Sidwell diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2a4eaeacb43..fe3e24d0b64 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4207,9 +4207,6 @@ pushdecl (x) them there. */ struct binding_level *b = current_binding_level->level_chain; - /* Skip the ctor/dtor cleanup level. */ - b = b->level_chain; - /* ARM $8.3 */ if (b->parm_flag == 1) { @@ -14054,6 +14051,14 @@ begin_function_body () { tree stmt; + if (processing_template_decl) + /* Do nothing now. */; + else + /* Always keep the BLOCK node associated with the outermost pair of + curly braces of a function. These are needed for correct + operation of dwarfout.c. */ + keep_next_level (1); + stmt = begin_compound_stmt (0); COMPOUND_STMT_BODY_BLOCK (stmt) = 1; @@ -14064,11 +14069,6 @@ begin_function_body () else if (DECL_DESTRUCTOR_P (current_function_decl)) begin_destructor_body (); - /* Always keep the BLOCK node associated with the outermost pair of - curly braces of a function. These are needed for correct - operation of dwarfout.c. */ - keep_next_level (1); - return stmt; } diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 3aaedafdd93..f159f446e36 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -668,11 +668,6 @@ emit_base_init (mem_init_list, base_init_list) int i; int n_baseclasses = BINFO_N_BASETYPES (t_binfo); - /* We did a keep_next_level (1) in begin_function_body. We don't want - that to apply to any blocks generated for member initializers, so - clear it out. */ - keep_next_level (0); - mem_init_list = sort_member_init (t, mem_init_list); sort_base_init (t, base_init_list, &rbase_init_list, &vbase_init_list); @@ -753,9 +748,6 @@ emit_base_init (mem_init_list, base_init_list) perform_member_init (member, init, from_init_list); mem_init_list = TREE_CHAIN (mem_init_list); } - - /* And restore it. */ - keep_next_level (1); } /* Returns the address of the vtable (i.e., the value that should be diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 420e428f019..f6dba7ec4ce 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -758,9 +758,16 @@ eat_saved_input: | END_OF_SAVED_INPUT ; +/* The outermost block of a function really begins before the + mem-initializer-list, so we open one there and suppress the one that + actually corresponds to the curly braces. */ function_body: - .begin_function_body ctor_initializer_opt compstmt - { + .begin_function_body ctor_initializer_opt save_lineno '{' + { $$ = begin_compound_stmt (/*has_no_scope=*/1); } + compstmtend + { + STMT_LINENO ($5) = $3; + finish_compound_stmt (/*has_no_scope=*/1, $5); finish_function_body ($1); } ; -- 2.30.2