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

From-SVN: r198010

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

index 14da63ed874136cbacff1d6a742fdfa10e087ea5..16da04cb1f21cf9656f8929c1ff2b6438af62782 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-11  Release Manager
 
        * GCC 4.7.3 released.
index 8735c8c799d50f5d3fd596641ecdd2b56c89f177..e189ef90f02c5b39afa7238d55e5272a3a61b187 100644 (file)
@@ -8959,13 +8959,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)
@@ -8976,8 +8975,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 = VEC_index (tree, stmt_list_stack,
-                        VEC_length (tree, stmt_list_stack) - 1 - skip);
+  stmt_list = VEC_index (tree, 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){}
+        }
+    }();
+}