diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 13 | ||||
-rw-r--r-- | lib/Serialization/ASTReaderStmt.cpp | 1 | ||||
-rw-r--r-- | lib/Serialization/ASTWriterStmt.cpp | 1 |
3 files changed, 13 insertions, 2 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 382e9bb185..db287515ce 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/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, diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index e53bf716a8..a6da3c7296 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -1112,6 +1112,7 @@ void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) { VisitExpr(E); E->GlobalDelete = Record[Idx++]; E->ArrayForm = Record[Idx++]; + E->ArrayFormAsWritten = Record[Idx++]; E->OperatorDelete = cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])); E->Argument = Reader.ReadSubExpr(); E->Loc = Reader.ReadSourceLocation(Record, Idx); diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp index b9a22842b9..3701e0c146 100644 --- a/lib/Serialization/ASTWriterStmt.cpp +++ b/lib/Serialization/ASTWriterStmt.cpp @@ -1121,6 +1121,7 @@ void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) { VisitExpr(E); Record.push_back(E->isGlobalDelete()); Record.push_back(E->isArrayForm()); + Record.push_back(E->isArrayFormAsWritten()); Writer.AddDeclRef(E->getOperatorDelete(), Record); Writer.AddStmt(E->getArgument()); Writer.AddSourceLocation(E->getSourceRange().getBegin(), Record); |