]> granicus.if.org Git - clang/commitdiff
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

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

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

index 6f3937353c89fef1ca6278f176c8c5f11a0b2788..28b58279a5285fbd48111cc2d0152fab4b6af0c8 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 97915a0094ef33a572a6fef15dea2bec10d66cb4..1253db95d5af8cc1a85bcaf3c5904911bb130e2c 100644 (file)
@@ -18,4 +18,7 @@ int main() {
 (void *const)s; // ok
 
 (const void *const)s; // ok
+
+// rdar://12859590
+(SEL)sel_registerName("foo");  // ok
 }