objc: DOn't complain if a (SEL) expression is typecast
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 13 Dec 2012 00:42:06 +0000 (00:42 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 13 Dec 2012 00:42:06 +0000 (00:42 +0000)
to (SEL). Fixes // rdar://12859590

llvm-svn: 170058

clang/lib/Sema/SemaCast.cpp
clang/test/SemaObjC/warn-cast-of-sel-expr.m

index 6f39373..28b5827 100644 (file)
@@ -1479,6 +1479,8 @@ void Sema::CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
 static void DiagnoseCastOfObjCSEL(Sema &Self, const ExprResult &SrcExpr,
                                   QualType DestType) {
   QualType SrcType = SrcExpr.get()->getType();
+  if (Self.Context.hasSameType(SrcType, DestType))
+    return;
   if (const PointerType *SrcPtrTy = SrcType->getAs<PointerType>())
     if (SrcPtrTy->isObjCSelType()) {
       QualType DT = DestType;
index 97915a0..1253db9 100644 (file)
@@ -18,4 +18,7 @@ int main() {
 (void *const)s; // ok
 
 (const void *const)s; // ok
+
+// rdar://12859590
+(SEL)sel_registerName("foo");  // ok
 }