aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaCXXCast.cpp4
-rw-r--r--test/SemaObjCXX/cstyle-cast.mm20
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp
index 6b4f87ef1d..c11b5fdd75 100644
--- a/lib/Sema/SemaCXXCast.cpp
+++ b/lib/Sema/SemaCXXCast.cpp
@@ -1160,6 +1160,10 @@ bool Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr,
if (CastTy->isDependentType() || CastExpr->isTypeDependent())
return false;
+ // allow c-style cast of objective-c pointers as they are pervasive.
+ if (CastTy->isObjCObjectPointerType())
+ return false;
+
if (!CastTy->isLValueReferenceType() && !CastTy->isRecordType())
DefaultFunctionArrayConversion(CastExpr);
diff --git a/test/SemaObjCXX/cstyle-cast.mm b/test/SemaObjCXX/cstyle-cast.mm
new file mode 100644
index 0000000000..97b7af3133
--- /dev/null
+++ b/test/SemaObjCXX/cstyle-cast.mm
@@ -0,0 +1,20 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+@protocol P @end
+@interface I @end
+
+int main() {
+ void *cft;
+ id oct = (id)cft;
+
+ Class ccct;
+ ccct = (Class)cft;
+
+ I* iict = (I*)cft;
+
+ id<P> pid = (id<P>)cft;
+
+ I<P> *ip = (I<P>*)cft;
+
+}
+