diff options
author | Jason Merrill <jason@redhat.com> | 2005-09-27 12:04:25 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2005-09-27 12:04:25 -0400 |
commit | 86ad3aa989805482427d241e03aa9fae6390d30d (patch) | |
tree | 3bb0430180145c4c46eccc4eb0371b0a2aeead17 /gcc/cp/decl.c | |
parent | 8ec88e19de05f73576e780f06331a1906fefacc5 (diff) | |
download | gcc-86ad3aa989805482427d241e03aa9fae6390d30d.zip gcc-86ad3aa989805482427d241e03aa9fae6390d30d.tar.gz gcc-86ad3aa989805482427d241e03aa9fae6390d30d.tar.bz2 |
re PR c++/13764 (c++ front-end creates extra blocks)
PR c++/13764
* c-common.c (finish_fname_decls): Use append_to_statement_list_force.
* cp/cp-tree.h (FUNCTION_NEEDS_BODY_BLOCK): New macro.
* cp/name-lookup.c (pushdecl_maybe_friend): Check it.
* cp/decl.c (begin_function_body): Do nothing if it's false.
(finish_function_body): Ditto.
(outer_curly_brace_block): New fn.
(finish_function): Use it.
From-SVN: r104698
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e3dbc83..bd77e06 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10656,14 +10656,16 @@ finish_destructor_body (void) /* Do the necessary processing for the beginning of a function body, which in this case includes member-initializers, but not the catch clauses of a function-try-block. Currently, this means opening a binding level - for the member-initializers (in a ctor) and member cleanups (in a dtor). - In other functions, this isn't necessary, but it doesn't hurt. */ + for the member-initializers (in a ctor) and member cleanups (in a dtor). */ tree begin_function_body (void) { tree stmt; + if (! FUNCTION_NEEDS_BODY_BLOCK (current_function_decl)) + return NULL_TREE; + if (processing_template_decl) /* Do nothing now. */; else @@ -10694,6 +10696,9 @@ begin_function_body (void) void finish_function_body (tree compstmt) { + if (compstmt == NULL_TREE) + return; + /* Close the block. */ finish_compound_stmt (compstmt); @@ -10705,6 +10710,20 @@ finish_function_body (tree compstmt) finish_destructor_body (); } +/* Given a function, returns the BLOCK corresponding to the outermost level + of curly braces, skipping the artificial block created for constructor + initializers. */ + +static tree +outer_curly_brace_block (tree fndecl) +{ + tree block = BLOCK_SUBBLOCKS (DECL_INITIAL (fndecl)); + if (FUNCTION_NEEDS_BODY_BLOCK (current_function_decl)) + /* Skip the artificial function body block. */ + block = BLOCK_SUBBLOCKS (block); + return block; +} + /* Finish up a function declaration and compile that function all the way to assembler language output. The free the storage for the function definition. @@ -10836,9 +10855,7 @@ finish_function (int flags) the function so we know that their lifetime always ends with a return; see g++.dg/opt/nrv6.C. We could be more flexible if we were to do this optimization in tree-ssa. */ - && (outer = BLOCK_SUBBLOCKS (DECL_INITIAL (fndecl))) - /* Skip the artificial function body block. */ - && (outer = BLOCK_SUBBLOCKS (outer)) + && (outer = outer_curly_brace_block (fndecl)) && chain_member (r, BLOCK_VARS (outer))) finalize_nrv (&DECL_SAVED_TREE (fndecl), r, DECL_RESULT (fndecl)); |