]> granicus.if.org Git - clang/commitdiff
Allow static_cast to objective-c pointers.
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 10 May 2010 23:46:53 +0000 (23:46 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 10 May 2010 23:46:53 +0000 (23:46 +0000)
Fixes radar 7952457.

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

lib/Sema/SemaCXXCast.cpp
test/SemaObjCXX/void_to_obj.mm

index ba7e1ff6341b480f2bbaa1430aa23271eec630c9..b7b6c3535c57d44f3efbb84a55f2fb99f543ced5 100644 (file)
@@ -578,8 +578,9 @@ static TryCastResult TryStaticCast(Sema &Self, Expr *&SrcExpr,
           return TC_Success;
         }
       }
-      else if (CStyle && DestType->isObjCObjectPointerType()) {
-        // allow c-style cast of objective-c pointers as they are pervasive.
+      else if (DestType->isObjCObjectPointerType()) {
+        // allow both c-style cast and static_cast of objective-c pointers as 
+        // they are pervasive.
         Kind = CastExpr::CK_AnyPointerToObjCPointerCast;
         return TC_Success;
       }
index 52510c84f139acab66881ff93fc5d62b94b967ec..7dca9faa854438b54dcd32093ae84a2047aca9ea 100644 (file)
@@ -9,3 +9,18 @@ void func() {
 
   obj = vv; // expected-error{{assigning to 'XX *' from incompatible type 'void *'}}
 }
+
+// <rdar://problem/7952457>
+@interface I
+{
+  void* delegate;
+}
+- (I*) Meth;
+- (I*) Meth1;
+@end
+
+@implementation I 
+- (I*) Meth { return static_cast<I*>(delegate); }
+- (I*) Meth1 { return reinterpret_cast<I*>(delegate); }
+@end
+