The C++ delete expression strips cv-qualifiers from the pointed-to type. My previous fix eliminated this behavior, so bring it back again.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83113 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 5846866..0ad18cd 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -849,6 +849,18 @@
<< Ex->getSourceRange()))
return ExprError();
+ // C++ [expr.delete]p2:
+ // [Note: a pointer to a const type can be the operand of a
+ // delete-expression; it is not necessary to cast away the constness
+ // (5.2.11) of the pointer expression before it is used as the operand
+ // of the delete-expression. ]
+ ImpCastExprToType(Ex, Context.getPointerType(Context.VoidTy),
+ CastExpr::CK_NoOp);
+
+ // Update the operand.
+ Operand.take();
+ Operand = ExprArg(*this, Ex);
+
DeclarationName DeleteName = Context.DeclarationNames.getCXXOperatorName(
ArrayForm ? OO_Array_Delete : OO_Delete);