aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AST/ASTContext.cpp6
-rw-r--r--test/SemaObjC/conditional-expr-8.m25
2 files changed, 28 insertions, 3 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index f723f2a8b7..524a7563e6 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -4963,10 +4963,10 @@ QualType ASTContext::areCommonBaseCompatible(
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 @@ QualType ASTContext::areCommonBaseCompatible(
Result = getObjCObjectPointerType(Result);
return Result;
}
- }
+ } while ((LDecl = LDecl->getSuperClass()));
return QualType();
}
diff --git a/test/SemaObjC/conditional-expr-8.m b/test/SemaObjC/conditional-expr-8.m
new file mode 100644
index 0000000000..6799983e3b
--- /dev/null
+++ b/test/SemaObjC/conditional-expr-8.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://9296866
+
+@interface NSResponder
+@end
+
+
+@interface NSView : NSResponder
+@end
+
+@interface WebView : NSView
+@end
+
+@protocol WebDocumentView
+@end
+
+@implementation NSView
+
+- (void) FUNC : (id)s {
+ WebView *m_webView;
+ NSView <WebDocumentView> *documentView;
+ NSView *coordinateView = s ? documentView : m_webView;
+}
+@end
+