From: Jason Merrill Date: Mon, 15 Apr 2013 15:23:53 +0000 (-0400) Subject: re PR c++/56388 (catch(...) in lambda rejected) X-Git-Tag: releases/gcc-4.9.0~6421 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a68329c23e76f311a22744e1b0d48421c4a5ec32;p=thirdparty%2Fgcc.git re PR c++/56388 (catch(...) in lambda rejected) PR c++/56388 * semantics.c (insert_capture_proxy): Just use index 1 in the stmt_list_stack. From-SVN: r197981 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 623760776b55..eefd11ea8904 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-04-15 Jason Merrill + + PR c++/56388 + * semantics.c (insert_capture_proxy): Just use index 1 in the + stmt_list_stack. + 2013-04-12 Jakub Jelinek * error.c (cp_print_error_function, diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index a09a7f480edc..2784d797bdb0 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -9265,13 +9265,12 @@ void insert_capture_proxy (tree var) { cp_binding_level *b; - int skip; tree stmt_list; /* Put the capture proxy in the extra body block so that it won't clash with a later local variable. */ b = current_binding_level; - for (skip = 0; ; ++skip) + for (;;) { cp_binding_level *n = b->level_chain; if (n->kind == sk_function_parms) @@ -9282,7 +9281,7 @@ insert_capture_proxy (tree var) /* And put a DECL_EXPR in the STATEMENT_LIST for the same block. */ var = build_stmt (DECL_SOURCE_LOCATION (var), DECL_EXPR, var); - stmt_list = (*stmt_list_stack)[stmt_list_stack->length () - 1 - skip]; + stmt_list = (*stmt_list_stack)[1]; gcc_assert (stmt_list); append_to_statement_list_force (var, &stmt_list); } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh3.C new file mode 100644 index 000000000000..10dc6e36d2bb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh3.C @@ -0,0 +1,14 @@ +// PR c++/56388 +// { dg-require-effective-target c++11 } + +int main() +{ + bool /*const*/ condition = false; + + [&]{ + try{} + catch(...){ + if(condition){} + } + }(); +}