[cfe-commits] r129718 - in /cfe/trunk: lib/AST/ASTContext.cpp test/SemaObjC/conditional-expr-8.m

Fariborz Jahanian fjahanian at apple.com
Mon Apr 18 14:16:59 PDT 2011


Author: fjahanian
Date: Mon Apr 18 16:16:59 2011
New Revision: 129718

URL: http://llvm.org/viewvc/llvm-project?rev=129718&view=rev
Log:
Fix a bug in calculation of composite type
of conditional expressions of objc pointer types
where one type is the immediate base type of the
other. // rdar://9296866

Added:
    cfe/trunk/test/SemaObjC/conditional-expr-8.m
Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=129718&r1=129717&r2=129718&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Apr 18 16:16:59 2011
@@ -4963,10 +4963,10 @@
   const ObjCObjectType *RHS = Rptr->getObjectType();
   const ObjCInterfaceDecl* LDecl = LHS->getInterface();
   const ObjCInterfaceDecl* RDecl = RHS->getInterface();
-  if (!LDecl || !RDecl)
+  if (!LDecl || !RDecl || (LDecl == RDecl))
     return QualType();
   
-  while ((LDecl = LDecl->getSuperClass())) {
+  do {
     LHS = cast<ObjCInterfaceType>(getObjCInterfaceType(LDecl));
     if (canAssignObjCInterfaces(LHS, RHS)) {
       llvm::SmallVector<ObjCProtocolDecl *, 8> Protocols;
@@ -4978,7 +4978,7 @@
       Result = getObjCObjectPointerType(Result);
       return Result;
     }
-  }
+  } while ((LDecl = LDecl->getSuperClass()));
     
   return QualType();
 }

Added: cfe/trunk/test/SemaObjC/conditional-expr-8.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/conditional-expr-8.m?rev=129718&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/conditional-expr-8.m (added)
+++ cfe/trunk/test/SemaObjC/conditional-expr-8.m Mon Apr 18 16:16:59 2011
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://9296866
+
+ at interface NSResponder
+ at end
+
+
+ at interface NSView : NSResponder
+ at end
+
+ at interface WebView : NSView
+ at end
+
+ at protocol WebDocumentView
+ at end
+
+ at implementation NSView
+
+- (void) FUNC : (id)s {
+  WebView *m_webView;
+  NSView <WebDocumentView> *documentView;
+  NSView *coordinateView = s ?  documentView : m_webView;
+}
+ at end
+





More information about the cfe-commits mailing list