[cfe-commits] [PATCH] Suggested rewording for lamba return values

Aaron Ballman aaron at aaronballman.com
Tue May 22 18:54:54 PDT 2012


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lambda_warning.patch
Type: application/octet-stream
Size: 1738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120522/ce7ee487/attachment.obj>


More information about the cfe-commits mailing list