This patch fixes a gcc 6. In gcc 6 we see an IDENTIFIER for functions (some) member fns that really resolve at parse time. We resolve them to the same thing at instantiation time, so users don't see a problem. Current GCC is cleaned up, so we see the actual decls when we need to. (and if we do defer to instantiation time we can't then find a member fn, which could change what we thought at parse time).

This fix is applied to gcc 6, and causes this capture when we see a raw identifier in this case.

trunk requires no such patch, but I'll put the testcase there.

nathan
--
Nathan Sidwell
2017-03-20  Nathan Sidwell  <nat...@acm.org>

	PR c++/80091
	* lambda.c (maybe_generic_this_capture): Capture when fn
	is an identifier node.

Index: cp/lambda.c
===================================================================
--- cp/lambda.c	(revision 246279)
+++ cp/lambda.c	(working copy)
@@ -809,8 +809,9 @@ maybe_generic_this_capture (tree object,
 	  {
 	    tree fn = OVL_CURRENT (fns);
 
-	    if ((!id_expr || TREE_CODE (fn) == TEMPLATE_DECL)
-		&& DECL_NONSTATIC_MEMBER_FUNCTION_P (fn))
+	    if (identifier_p (fns)
+		|| ((!id_expr || TREE_CODE (fn) == TEMPLATE_DECL)
+		    && DECL_NONSTATIC_MEMBER_FUNCTION_P (fn)))
 	      {
 		/* Found a non-static member.  Capture this.  */
 		lambda_expr_this_capture (lam, true);
Index: testsuite/g++.dg/cpp0x/pr80091.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr80091.C	(nonexistent)
+++ testsuite/g++.dg/cpp0x/pr80091.C	(working copy)
@@ -0,0 +1,12 @@
+// { dg-do compile { target c++11 } }
+
+// PR 80091 ICE with member fn call from lambda in template
+
+struct A {
+  void m_fn1();
+};
+template <int> struct B : A {
+  void m_fn2() {
+    [&] { m_fn1(); };
+  }
+};

Reply via email to