]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/56388 (catch(...) in lambda rejected)
authorJason Merrill <jason@redhat.com>
Mon, 15 Apr 2013 15:23:53 +0000 (11:23 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 15 Apr 2013 15:23:53 +0000 (11:23 -0400)
PR c++/56388
* semantics.c (insert_capture_proxy): Just use index 1 in the
stmt_list_stack.

From-SVN: r197981

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh3.C [new file with mode: 0644]

index 623760776b5599c159c840799f520aa149471021..eefd11ea8904ff1227e79844ac6ccdc5bc3a1e02 100644 (file)
@@ -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,
index a09a7f480edc857c828c007ef6004c2b2b271764..2784d797bdb06631ee533601f31c7fcfbc0bc9a5 100644 (file)
@@ -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 (file)
index 0000000..10dc6e3
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/56388
+// { dg-require-effective-target c++11 }
+
+int main()
+{
+    bool /*const*/ condition = false;
+
+    [&]{
+        try{}
+        catch(...){
+            if(condition){}
+        }
+    }();
+}