Files
gcc-reflection/gcc/testsuite/obj-c++.dg/lambda-0.mm
Iain Sandoe e8ef82d74f Allow Objective-c++ to recognise lambdas.
gcc/cp:

	* parser.c (cp_parser_primary_expression): If parsing an
	objective-c++ message expression fails, see if a lambda is present.
	(cp_parser_objc_message_receiver): Don't assume that, if a message
	receiver expression fails, it is a hard error.

gcc/testsuite:

	* obj-c++.dg/lambda-0.mm New.
	* obj-c++.dg/lambda-1.mm New.
	* obj-c++.dg/syntax-error-6.mm Adjust for revised error messages.

From-SVN: r219125
2014-12-31 13:58:16 +00:00

23 lines
390 B
Plaintext

// Contributed by Iain Sandoe <iain@codesourcery.com>, December 2014. */
// { dg-do compile }
// { dg-options "-std=c++11" }
template<class Function>
Function thing(Function fn, int a)
{
fn(a);
return fn;
}
int
test (int *arr, unsigned n)
{
int total = 0;
for (unsigned i=0; i<n; i++) {
int a = arr[i];
thing ([&total] (int a) { total += a; }, a);
}
return total;
}