When a lambda expression omits the return type information, the
standard requires the lambda statement body to be a single return
statement.  However, as a language extension, we (and several other
compilers) support determining the return type if all of the
function's return types agree.

The problem is, the wording for the warning we emit is a bit difficult
to parse.  It's a semantically correct statement, but it's not
immediately obvious what the problem is or how to rectify it.
Consider:

auto i = []() { static const int foo = 12; return &foo; }();

This will emit a diagnostic that says "C++11 requires lambda with
omitted result type to consist of a single return statement" --
however, a likely initial response to this is "but I do only have a
single return statement!"

This patch rewords the diagnostic to be a bit more clear (hopefully):
"C++11 requires a lambda expression with omitted result type to
consist solely of a return statement"

Thoughts?

~Aaron

Attachment: lambda_warning.patch
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to