[cfe-commits] r103447 - in /cfe/trunk: lib/Sema/SemaCXXCast.cpp test/SemaObjCXX/void_to_obj.mm
Fariborz Jahanian
fjahanian at apple.com
Mon May 10 16:46:53 PDT 2010
Author: fjahanian
Date: Mon May 10 18:46:53 2010
New Revision: 103447
URL: http://llvm.org/viewvc/llvm-project?rev=103447&view=rev
Log:
Allow static_cast to objective-c pointers.
Fixes radar 7952457.
Modified:
cfe/trunk/lib/Sema/SemaCXXCast.cpp
cfe/trunk/test/SemaObjCXX/void_to_obj.mm
Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=103447&r1=103446&r2=103447&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Mon May 10 18:46:53 2010
@@ -578,8 +578,9 @@
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;
}
Modified: cfe/trunk/test/SemaObjCXX/void_to_obj.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/void_to_obj.mm?rev=103447&r1=103446&r2=103447&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/void_to_obj.mm (original)
+++ cfe/trunk/test/SemaObjCXX/void_to_obj.mm Mon May 10 18:46:53 2010
@@ -9,3 +9,18 @@
obj = vv; // expected-error{{assigning to 'XX *' from incompatible type 'void *'}}
}
+
+// <rdar://problem/7952457>
+ at interface I
+{
+ void* delegate;
+}
+- (I*) Meth;
+- (I*) Meth1;
+ at end
+
+ at implementation I
+- (I*) Meth { return static_cast<I*>(delegate); }
+- (I*) Meth1 { return reinterpret_cast<I*>(delegate); }
+ at end
+
More information about the cfe-commits
mailing list