[cfe-commits] [PATCH] Parsing C++0x lambda expressions

David Blaikie dblaikie at gmail.com
Fri Jul 29 23:53:27 PDT 2011


> Okay, we'd like some additional tests in here to make sure that the disambiguation is working properly, the diagnostics work properly, etc.

I took the liberty of helping out by having a go at some test cases
for John. This covers some positive/negative cases (lambdas in
objc(negative), objc++(negative), objc++0x, c++(negative), c++0x). I
found a couple of bugs in the process:

1) the comma separating elements in the capture list was not being consumed.
2) use of &this as the first capture produced no diagnostic (the test
for "&," at the start of a capture was expressed as "current token is
& and next token is not an identifier" - which was satisfied, so the
amp was consumed & then 'this' was seen as a nomal value capture
instead of an erroneous reference capture of this)

> +// FIXME: -Wno-return-type is necessary because we do not yet handle lambda
> +// scopes properly. My first thought was that the flag would be unnecessary
> +// because it is a semantic (not syntactic) check. I cannot find documentation
> +// on the -verify flag, but removing it does not remove the return type check.
>
> Grep around the test-suite for "expected-warning"; that's how to get -verify to pass cleanly. Basically, -verify checks the compiler's generated diagnostics against the expected-warning and expected-error markup in the file, a bit like DejaGNU has dg-warning and dg-error for GCC (but built into Clang).

I think the thing John was getting at mostly was that it was weird
that no-return-type was necessary at the moment. Rather than trying to
figure out this issue/fix it, I switched to using an expected-error
for the return type problem, in this way when the issue is fixed we
won't accidentally leave the warning suppression in (since the test
will then fail until the suppression is removed).

I hope this helps,

- David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lambda-parse.patch
Type: text/x-patch
Size: 17157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110729/0795e060/attachment.bin>


More information about the cfe-commits mailing list