]> granicus.if.org Git - clang/commitdiff
Fixed missing cast and wrong cast kind in delete expression.
authorAbramo Bagnara <abramo.bagnara@gmail.com>
Wed, 16 Nov 2011 15:42:13 +0000 (15:42 +0000)
committerAbramo Bagnara <abramo.bagnara@gmail.com>
Wed, 16 Nov 2011 15:42:13 +0000 (15:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144796 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp

index b4db312d6cc2a3669df7460c66c14a4fb39faebd..edb4fef348434f47fed143a82993773f111abae5 100644 (file)
@@ -1861,14 +1861,17 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
       }
     }
 
+    // Perform lvalue-to-rvalue cast, if needed.
+    Ex = DefaultLvalueConversion(Ex.take());
+
     // 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. ]
     if (!Context.hasSameType(Ex.get()->getType(), Context.VoidPtrTy))
-      Ex = Owned(ImplicitCastExpr::Create(Context, Context.VoidPtrTy, CK_NoOp,
-                                          Ex.take(), 0, VK_RValue));
+      Ex = Owned(ImplicitCastExpr::Create(Context, Context.VoidPtrTy,
+                                          CK_BitCast, Ex.take(), 0, VK_RValue));
 
     if (Pointee->isArrayType() && !ArrayForm) {
       Diag(StartLoc, diag::warn_delete_array_type)