2017-03-20 Nathan Sidwell <nathan@acm.org>
PR c++/80091
* lambda.c (maybe_generic_this_capture): Capture when fn
is an identifier node.
===================================================================
@@ -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);
===================================================================
@@ -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(); };
+ }
+};