diff options
author | Jason Merrill <jason@redhat.com> | 2010-10-27 11:48:09 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-10-27 11:48:09 -0400 |
commit | e02927a11ac5a16f42193c198b300fda15230404 (patch) | |
tree | 2b370c8b3b7b55ab734d0d205edaa26482269ff5 /gcc/cp | |
parent | bc8a0bd9fc9bc846333b2a50072558ce9b623af7 (diff) | |
download | gcc-e02927a11ac5a16f42193c198b300fda15230404.zip gcc-e02927a11ac5a16f42193c198b300fda15230404.tar.gz gcc-e02927a11ac5a16f42193c198b300fda15230404.tar.bz2 |
semantics.c (finish_compound_stmt): Avoid creating an unnecessary BIND_EXPR.
* semantics.c (finish_compound_stmt): Avoid creating an
unnecessary BIND_EXPR.
From-SVN: r166006
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7646dca..178bed6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2010-10-27 Jason Merrill <jason@redhat.com> + * semantics.c (finish_compound_stmt): Avoid creating an + unnecessary BIND_EXPR. + * call.c (convert_like_real): Don't check narrowing if the element is also an initializer-list. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index ae3bf90..0012bdd 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1208,7 +1208,19 @@ void finish_compound_stmt (tree stmt) { if (TREE_CODE (stmt) == BIND_EXPR) - BIND_EXPR_BODY (stmt) = do_poplevel (BIND_EXPR_BODY (stmt)); + { + tree body = do_poplevel (BIND_EXPR_BODY (stmt)); + /* If the STATEMENT_LIST is empty and this BIND_EXPR isn't special, + discard the BIND_EXPR so it can be merged with the containing + STATEMENT_LIST. */ + if (TREE_CODE (body) == STATEMENT_LIST + && STATEMENT_LIST_HEAD (body) == NULL + && !BIND_EXPR_BODY_BLOCK (stmt) + && !BIND_EXPR_TRY_BLOCK (stmt)) + stmt = body; + else + BIND_EXPR_BODY (stmt) = body; + } else if (STATEMENT_LIST_NO_SCOPE (stmt)) stmt = pop_stmt_list (stmt); else |