aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-12-08 19:22:33 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-12-08 19:22:33 +0000
commitebea307a766729981ed923db9b77543437d726dc (patch)
treecf913276a389ea99cfe3c786883ae7393f023790
parent52efc3fdbabaf4848f47887eda130b0961508cd0 (diff)
Patch to allow cstyle cast of objective-c pointers in objective-c++
mode as they are pervasive. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90867 91177308-0d34-0410-b5e6-96231b3b80d8
-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;
+
+}
+