Added a better diagnostic when using the delete operator with lambdas
authorNicolas Lesser <blitzrakete@gmail.com>
Sun, 19 May 2019 15:07:58 +0000 (15:07 +0000)
committerNicolas Lesser <blitzrakete@gmail.com>
Sun, 19 May 2019 15:07:58 +0000 (15:07 +0000)
commitf53d1727107ed84a1153b7db193cfb9c18c5e2a9
treecb7c33ae9192c96d41ae85b9767209410e0b06f7
parent9ef99b4b118bf6b2b94684c1241450a639c9203f
Added a better diagnostic when using the delete operator with lambdas

Summary:
This adds a new error for missing parentheses around lambdas in delete operators.

```
int main() {
  delete []() { return new int(); }();
}
```

This will result in:

```
test.cpp:2:3: error: '[]' after delete interpreted as 'delete[]'
  delete []() { return new int(); }();
  ^~~~~~~~~
test.cpp:2:9: note: add parentheses around the lambda
  delete []() { return new int(); }();
        ^
        (                          )
```

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: riccibruno, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D36357

llvm-svn: 361119
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParseExprCXX.cpp
clang/test/FixIt/fixit-cxx0x.cpp
clang/test/Parser/cxx0x-lambda-expressions.cpp
clang/test/SemaCXX/new-delete-0x.cpp