[cfe-commits] r90867 - in /cfe/trunk: lib/Sema/SemaCXXCast.cpp test/SemaObjCXX/cstyle-cast.mm

Fariborz Jahanian fjahanian at apple.com
Tue Dec 8 11:22:37 PST 2009


Author: fjahanian
Date: Tue Dec  8 13:22:33 2009
New Revision: 90867

URL: http://llvm.org/viewvc/llvm-project?rev=90867&view=rev
Log:
Patch to allow cstyle cast of objective-c pointers in objective-c++
mode as they are pervasive.


Added:
    cfe/trunk/test/SemaObjCXX/cstyle-cast.mm
Modified:
    cfe/trunk/lib/Sema/SemaCXXCast.cpp

Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=90867&r1=90866&r2=90867&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Tue Dec  8 13:22:33 2009
@@ -1160,6 +1160,10 @@
   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);
 

Added: cfe/trunk/test/SemaObjCXX/cstyle-cast.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/cstyle-cast.mm?rev=90867&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjCXX/cstyle-cast.mm (added)
+++ cfe/trunk/test/SemaObjCXX/cstyle-cast.mm Tue Dec  8 13:22:33 2009
@@ -0,0 +1,20 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+ at protocol P @end
+ at 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;
+  
+}
+





More information about the cfe-commits mailing list