This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/54122 (ICE with 'this' capture)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 05 Feb 2013 23:24:20 -0500
- Subject: C++ PATCH for c++/54122 (ICE with 'this' capture)
We were crashing in lvalue_kind because we were trying to test whether a
NULL type was a METHOD_TYPE. The reason we would care whether the type
is a METHOD_TYPE is lost to history; the change was there in the first
version of that function that appeared in 1995.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 19ec4361510b137bc60631193cd47e378fc1b314
Author: Jason Merrill <jason@redhat.com>
Date: Tue Feb 5 23:04:01 2013 -0500
PR c++/54122
* tree.c (lvalue_kind) [INDIRECT_REF]: Don't check for
METHOD_TYPE.
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index d1f14fc..18d9a98 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -143,9 +143,7 @@ lvalue_kind (const_tree ref)
case ARRAY_REF:
case PARM_DECL:
case RESULT_DECL:
- if (TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
- return clk_ordinary;
- break;
+ return clk_ordinary;
/* A scope ref in a template, left as SCOPE_REF to support later
access checking. */
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this7.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this7.C
new file mode 100644
index 0000000..6e25c33
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this7.C
@@ -0,0 +1,11 @@
+// PR c++/54122
+// { dg-options -std=c++11 }
+
+enum E { F };
+
+template <typename A>
+struct C
+{
+ E e;
+ void f () { auto l = [&](void)->void { if (e == F) return; }; }
+};