From ebea307a766729981ed923db9b77543437d726dc Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 8 Dec 2009 19:22:33 +0000 Subject: [PATCH] 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 --- lib/Sema/SemaCXXCast.cpp | 4 ++++ test/SemaObjCXX/cstyle-cast.mm | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/SemaObjCXX/cstyle-cast.mm 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

pid = (id

)cft; + + I

*ip = (I

*)cft; + +} + -- 2.40.0