HomePhabricator

Added a better diagnostic when using the delete operator with lambdas

Description

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

Details

Committed
Rakete1111Sun, May 19, 8:07 AM
Reviewer
rsmith
Differential Revision
D36357: Added a better diagnostic when using the delete operator with lambdas
Branches
Unknown
Tags
Unknown