Patchwork C++ PATCH for c++/54122 (ICE with 'this' capture)

login
register
mail settings
Submitter Jason Merrill
Date Feb. 6, 2013, 4:24 a.m.
Message ID <5111DAF4.70206@redhat.com>
Download mbox | patch
Permalink /patch/218486/
State New
Headers show

Comments

Jason Merrill - Feb. 6, 2013, 4:24 a.m.
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.

Patch

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; }; }
+};