diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-09-13 20:15:54 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-09-13 20:15:54 +0000 |
| commit | 14ec9f674a566cc11a31fbb95cb7486869795a74 (patch) | |
| tree | f447f1653b9be91adce411bb3d528d7934c67711 /clang/lib/Sema/SemaExprCXX.cpp | |
| parent | 9b0d1cf47c041942b24c1e98e85648bdcc6174f1 (diff) | |
| download | bcm5719-llvm-14ec9f674a566cc11a31fbb95cb7486869795a74.tar.gz bcm5719-llvm-14ec9f674a566cc11a31fbb95cb7486869795a74.zip | |
When applying 'delete' on a pointer-to-array type match GCC and EDG behavior and treat it as 'delete[]'.
Also offer a fix-it hint adding '[]'.
llvm-svn: 113778
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 382e9bb1851..db287515ce9 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1438,6 +1438,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, // DR599 amends "pointer type" to "pointer to object type" in both cases. FunctionDecl *OperatorDelete = 0; + bool ArrayFormAsWritten = ArrayForm; if (!Ex->isTypeDependent()) { QualType Type = Ex->getType(); @@ -1514,7 +1515,14 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, // of the delete-expression. ] ImpCastExprToType(Ex, Context.getPointerType(Context.VoidTy), CK_NoOp); - + + if (Pointee->isArrayType() && !ArrayForm) { + Diag(StartLoc, diag::warn_delete_array_type) + << Type << Ex->getSourceRange() + << FixItHint::CreateInsertion(PP.getLocForEndOfToken(StartLoc), "[]"); + ArrayForm = true; + } + DeclarationName DeleteName = Context.DeclarationNames.getCXXOperatorName( ArrayForm ? OO_Array_Delete : OO_Delete); @@ -1548,7 +1556,8 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, } return Owned(new (Context) CXXDeleteExpr(Context.VoidTy, UseGlobal, ArrayForm, - OperatorDelete, Ex, StartLoc)); + ArrayFormAsWritten, OperatorDelete, + Ex, StartLoc)); } /// \brief Check the use of the given variable as a C++ condition in an if, |

