[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun May 5 10:36:47 PDT 2019
rsmith added a comment.
In D36357#1491081 <https://reviews.llvm.org/D36357#1491081>, @Rakete1111 wrote:
> @rsmith One last question: The fixit diagnostic seems to be inconsistent with the rest?
>
> main.cpp:2:3: error: '[]' after delete interpreted as 'delete[]'
> delete[] { return new int; }
> ^~~~~~~~
> ( )
>
>
> Shouldn't the `^~~~~~~` be starting at the `[]`?
Pointing the caret at the `[` might be clearer, but I think that's fine too.
In D36357#1491082 <https://reviews.llvm.org/D36357#1491082>, @Rakete1111 wrote:
> Is this also okay?
>
> main.cpp:2:9: warning: lambda expressions are incompatible with C++98 [-Wc++98-compat]
> delete[] { return new int; }
> ^
> main.cpp:2:3: error: '[]' after delete interpreted as 'delete[]'; add parentheses to treat this as a lambda-expression
> delete[] { return new int; }
> ^~~~~~~~
> ( )
>
Hmm. It would be better to produce the error first, but that would make it more difficult to get the fixit hint right. I suppose in the case where we've already decided we're going to diagnose, we could perform a tentative parse and skip to the `}` of the lambda.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D36357/new/
https://reviews.llvm.org/D36357
More information about the cfe-commits
mailing list