From e02927a11ac5a16f42193c198b300fda15230404 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 27 Oct 2010 11:48:09 -0400 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/semantics.c | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7646dcacc9d..178bed6cd68 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2010-10-27 Jason Merrill + * 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 ae3bf90295d..0012bdde49f 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