This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/61151 (ICE with nested lambda in template)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 13 May 2014 13:56:31 -0400
- Subject: C++ PATCH for c++/61151 (ICE with nested lambda in template)
- Authentication-results: sourceware.org; auth=none
My patch for 60092 failed to consider that we need to avoid obscuring a
capture proxy for 'this', not just 'this' itself.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit e40151a986a68e29c169913e36b76fa4310379d7
Author: Jason Merrill <jason@redhat.com>
Date: Tue May 13 12:52:37 2014 -0400
PR c++/61151
* semantics.c (is_this_parameter): Allow capture proxies too.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index d925f5c..583b870 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -8158,8 +8158,10 @@ maybe_initialize_constexpr_call_table (void)
bool
is_this_parameter (tree t)
{
- return (TREE_CODE (t) == PARM_DECL
- && DECL_NAME (t) == this_identifier);
+ if (!DECL_P (t) || DECL_NAME (t) != this_identifier)
+ return false;
+ gcc_assert (TREE_CODE (t) == PARM_DECL || is_capture_proxy (t));
+ return true;
}
/* We have an expression tree T that represents a call, either CALL_EXPR
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this18.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this18.C
new file mode 100644
index 0000000..fec2da6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this18.C
@@ -0,0 +1,30 @@
+// PR c++/61151
+// { dg-do compile { target c++11 } }
+
+struct B
+{
+ void foo () {}
+};
+
+template <class>
+struct A
+{
+ template <class> void bar ();
+ B a;
+};
+
+template <class T>
+template <class U>
+void
+A<T>::bar ()
+{
+ auto f = [this] () { auto g = [=] () { a.foo (); }; g (); };
+ f ();
+}
+
+int
+main ()
+{
+ A<int> a;
+ a.bar <int> ();
+}