diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-09 19:01:51 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-09 19:01:51 +0000 |
| commit | 10c6072d615a45617cf3e26c9b5b8f7f4d0046ef (patch) | |
| tree | ee534ed984b322092033b01bf14c242f3fa05857 | |
| parent | 85383182ecd23fdb70cd5cb7d81fea5b583b6031 (diff) | |
| download | bcm5719-llvm-10c6072d615a45617cf3e26c9b5b8f7f4d0046ef.tar.gz bcm5719-llvm-10c6072d615a45617cf3e26c9b5b8f7f4d0046ef.zip | |
In 'delete []', the '[]' never starts a lambda. Update a FIXME with a standard reference and add a test.
llvm-svn: 161604
| -rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 12 | ||||
| -rw-r--r-- | clang/test/Parser/cxx0x-lambda-expressions.cpp | 7 |
2 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 592a3cc160b..afac25793a7 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -2403,10 +2403,14 @@ Parser::ParseCXXDeleteExpression(bool UseGlobal, SourceLocation Start) { // Array delete? bool ArrayDelete = false; if (Tok.is(tok::l_square) && NextToken().is(tok::r_square)) { - // FIXME: This could be the start of a lambda-expression. We should - // disambiguate this, but that will require arbitrary lookahead if - // the next token is '(': - // delete [](int*){ /* ... */ + // C++11 [expr.delete]p1: + // Whenever the delete keyword is followed by empty square brackets, it + // shall be interpreted as [array delete]. + // [Footnote: A lambda expression with a lambda-introducer that consists + // of empty square brackets can follow the delete keyword if + // the lambda expression is enclosed in parentheses.] + // FIXME: Produce a better diagnostic if the '[]' is unambiguously a + // lambda-introducer. ArrayDelete = true; BalancedDelimiterTracker T(*this, tok::l_square); diff --git a/clang/test/Parser/cxx0x-lambda-expressions.cpp b/clang/test/Parser/cxx0x-lambda-expressions.cpp index 9c719414212..7e9d4751e6e 100644 --- a/clang/test/Parser/cxx0x-lambda-expressions.cpp +++ b/clang/test/Parser/cxx0x-lambda-expressions.cpp @@ -40,4 +40,11 @@ class C { int a5[3] = { []{return 0;}() }; int a6[1] = {[this] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'C *'}} } + + void delete_lambda(int *p) { + delete [] p; + delete [] (int*) { new int }; // ok, compound-literal, not lambda + delete [] { return new int; } (); // expected-error{{expected expression}} + delete [&] { return new int; } (); // ok, lambda + } }; |

