Allow static_cast to objective-c pointers.

Fixes radar 7952457.

llvm-svn: 103447
This commit is contained in:
Fariborz Jahanian 2010-05-10 23:46:53 +00:00
parent 341db487a8
commit eee1669adb
2 changed files with 18 additions and 2 deletions

View 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;
}

View 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