]> granicus.if.org Git - clang/commitdiff
Perform l2r conversions on delete operands before doing
authorJohn McCall <rjmccall@apple.com>
Fri, 9 Mar 2012 04:08:29 +0000 (04:08 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 9 Mar 2012 04:08:29 +0000 (04:08 +0000)
type-analysis;  otherwise, we just completely do the
wrong thing for placeholders.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152375 91177308-0d34-0410-b5e6-96231b3b80d8

a.out [new file with mode: 0755]
lib/Sema/SemaExprCXX.cpp
test/SemaObjCXX/properties.mm

diff --git a/a.out b/a.out
new file mode 100755 (executable)
index 0000000..1151e9b
Binary files /dev/null and b/a.out differ
index dca77198946255f67f9f2fa874f609f82d4fda48..6c7bdeb7422880e6fc610616e5404fa5b41e3fde 100644 (file)
@@ -1972,6 +1972,9 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
   bool UsualArrayDeleteWantsSize = false;
 
   if (!Ex.get()->isTypeDependent()) {
+    // Perform lvalue-to-rvalue cast, if needed.
+    Ex = DefaultLvalueConversion(Ex.take());
+
     QualType Type = Ex.get()->getType();
 
     if (const RecordType *Record = Type->getAs<RecordType>()) {
@@ -2053,9 +2056,6 @@ 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
index 0264f463adafce1f645ee742d74bda37583d6323..4d107c0356e5a90672eb457dac9a320c4310ec6a 100644 (file)
@@ -85,3 +85,24 @@ void test6_template(T *t6) {
 }
 
 template void test6_template(Test6*);
+
+// rdar://problem/10965735
+struct Test7PointerMaker {
+  operator char *() const;
+};
+@interface Test7
+- (char*) implicit_property;
+- (char) bad_implicit_property;
+- (Test7PointerMaker) implicit_struct_property;
+@property int *explicit_property;
+@property int bad_explicit_property;
+@property Test7PointerMaker explicit_struct_property;
+@end
+void test7(Test7 *ptr) {
+  delete ptr.implicit_property;
+  delete ptr.bad_implicit_property; // expected-error {{cannot delete expression of type 'char'}}
+  delete ptr.explicit_property;
+  delete ptr.bad_explicit_property; // expected-error {{cannot delete expression of type 'int'}}
+  delete ptr.implicit_struct_property;
+  delete ptr.explicit_struct_property;
+}