P0722R2: The first parameter in an implicit call to a destroying operator
delete should be a cv-unqualified pointer to the deleted object.
llvm-svn: 319858
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 56b14dd..e4634d9 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -3293,6 +3293,15 @@
// is trivial and left to AST consumers to handle.
QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
if (!IsVirtualDelete && !ParamType->getPointeeType()->isVoidType()) {
+ Qualifiers Qs = Pointee.getQualifiers();
+ if (Qs.hasCVRQualifiers()) {
+ // Qualifiers are irrelevant to this conversion; we're only looking
+ // for access and ambiguity.
+ Qs.removeCVRQualifiers();
+ QualType Unqual = Context.getPointerType(
+ Context.getQualifiedType(Pointee.getUnqualifiedType(), Qs));
+ Ex = ImpCastExprToType(Ex.get(), Unqual, CK_NoOp);
+ }
Ex = PerformImplicitConversion(Ex.get(), ParamType, AA_Passing);
if (Ex.isInvalid())
return ExprError();