===================================================================
@@ -9892,7 +9892,12 @@ cp_parser_lambda_body (cp_parser* parser, tree lam
if (cp_parser_parse_definitely (parser))
{
if (!processing_template_decl)
- apply_deduced_return_type (fco, lambda_return_type (expr));
+ {
+ tree type = lambda_return_type (expr);
+ apply_deduced_return_type (fco, type);
+ if (type == error_mark_node)
+ expr = error_mark_node;
+ }
/* Will get error here if type not deduced yet. */
finish_return_stmt (expr);
===================================================================
@@ -517,12 +517,12 @@ cxx_incomplete_type_diagnostic (const_tree value,
if (DECL_FUNCTION_MEMBER_P (member)
&& ! flag_ms_extensions)
emit_diagnostic (diag_kind, input_location, 0,
- "invalid use of member function "
- "(did you forget the %<()%> ?)");
+ "invalid use of member function %qD "
+ "(did you forget the %<()%> ?)", member);
else
emit_diagnostic (diag_kind, input_location, 0,
- "invalid use of member "
- "(did you forget the %<&%> ?)");
+ "invalid use of member %qD "
+ "(did you forget the %<&%> ?)", member);
}
break;
===================================================================
@@ -0,0 +1,10 @@
+// PR c++/67846
+// { dg-do compile { target c++11 } }
+
+class A
+{
+ void foo ()
+ {
+ [=] { return foo; }; // { dg-error "invalid use of member function" }
+ }
+};