aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-04-15 11:23:53 -0400
committerJason Merrill <jason@gcc.gnu.org>2013-04-15 11:23:53 -0400
commita68329c23e76f311a22744e1b0d48421c4a5ec32 (patch)
tree78d0c26d1b0965f62f5c7fec597905aa22efcd16
parent7b8265ba384990c3ba844abb0568bb8e770e06bc (diff)
downloadgcc-a68329c23e76f311a22744e1b0d48421c4a5ec32.zip
gcc-a68329c23e76f311a22744e1b0d48421c4a5ec32.tar.gz
gcc-a68329c23e76f311a22744e1b0d48421c4a5ec32.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/semantics.c5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh3.C14
3 files changed, 22 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6237607..eefd11e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2013-04-15 Jason Merrill <jason@redhat.com>
+
+ PR c++/56388
+ * semantics.c (insert_capture_proxy): Just use index 1 in the
+ stmt_list_stack.
+
2013-04-12 Jakub Jelinek <jakub@redhat.com>
* error.c (cp_print_error_function,
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index a09a7f4..2784d79 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 0000000..10dc6e3
--- /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){}
+ }
+ }();
+}