aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-12-13 00:42:06 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-12-13 00:42:06 +0000
commit0c252fa8b751be50f8b53ffdc6563dca609870fc (patch)
treed5850b6e2511e618fa317bac2341b2e44384eabe
parent206491dcbe1ed01ee8ce86a0ffe272d5d25491d3 (diff)
objc: DOn't complain if a (SEL) expression is typecast
to (SEL). Fixes // rdar://12859590 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170058 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaCast.cpp2
-rw-r--r--test/SemaObjC/warn-cast-of-sel-expr.m3
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp
index 6f3937353c..28b58279a5 100644
--- a/lib/Sema/SemaCast.cpp
+++ b/lib/Sema/SemaCast.cpp
@@ -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;
diff --git a/test/SemaObjC/warn-cast-of-sel-expr.m b/test/SemaObjC/warn-cast-of-sel-expr.m
index 97915a0094..1253db95d5 100644
--- a/test/SemaObjC/warn-cast-of-sel-expr.m
+++ b/test/SemaObjC/warn-cast-of-sel-expr.m
@@ -18,4 +18,7 @@ int main() {
(void *const)s; // ok
(const void *const)s; // ok
+
+// rdar://12859590
+(SEL)sel_registerName("foo"); // ok
}