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)
commitbc416fbc59511cf2199dbaa49501c16dac527b6a
treefd64dee06aa3ce3df10f15b4a6dffafe6f7b5c98
parent68bcda164b8dfc9f374bbd98db5012c0d0ebd33d
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361119 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseExprCXX.cpp
test/FixIt/fixit-cxx0x.cpp
test/Parser/cxx0x-lambda-expressions.cpp
test/SemaCXX/new-delete-0x.cpp