This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/56388 (lambdas and EH)


My code for inserting capture proxy DECL_EXPRs was assuming that there is one stmt_list_stack entry per cp_binding_level entry, but that isn't always the case. Conveniently, the stmt_list_stack entry we want will always be at index 1, since each function has its own stack.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.8.

commit 25d22d3ebea706ae32be404241cfe34d6b2ffefb
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 11 18:12:52 2013 -0400

    	PR c++/56388
    	* semantics.c (insert_capture_proxy): Just use index 1 in the
    	stmt_list_stack.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index a09a7f4..1ac38a3 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -9282,7 +9282,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){}
+        }
+    }();
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]