]> granicus.if.org Git - clang/commitdiff
Patch to allow cstyle cast of objective-c pointers in objective-c++
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 8 Dec 2009 19:22:33 +0000 (19:22 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 8 Dec 2009 19:22:33 +0000 (19:22 +0000)
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
test/SemaObjCXX/cstyle-cast.mm [new file with mode: 0644]

index 6b4f87ef1dfb28af65aa4e030909482cdb00bba3..c11b5fdd75b841b8a96146f1942848efe56970ed 100644 (file)
@@ -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 (file)
index 0000000..97b7af3
--- /dev/null
@@ -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;
+  
+}
+