Author: snaroff
Date: Wed Dec 10 14:07:25 2008
New Revision: 60845
URL: http://llvm.org/viewvc/llvm-project?rev=60845&view=rev
Log:
Fix <rdar://problem/6424347> clang on xcode: Assertion failed: (0 &&
"unexpected type"), function mergeTypes,
Added:
cfe/trunk/test/SemaObjC/method-conflict.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=60845&r1=60844&r2=60845&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Dec 10 14:07:25 2008
@@ -2126,35 +2126,35 @@
if (LHSClass == Type::ObjCQualifiedInterface) LHSClass = Type::ObjCInterface;
if (RHSClass == Type::ObjCQualifiedInterface) RHSClass = Type::ObjCInterface;
+ // ID is compatible with all qualified id types.
+ if (LHS->isObjCQualifiedIdType()) {
+ if (const PointerType *PT = RHS->getAsPointerType()) {
+ QualType pType = PT->getPointeeType();
+ if (isObjCIdType(pType))
+ return LHS;
+ // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS, true).
+ // Unfortunately, this API is part of Sema (which we don't have access
+ // to. Need to refactor. The following check is insufficient, since we
+ // need to make sure the class implements the protocol.
+ if (pType->isObjCInterfaceType())
+ return LHS;
+ }
+ }
+ if (RHS->isObjCQualifiedIdType()) {
+ if (const PointerType *PT = LHS->getAsPointerType()) {
+ QualType pType = PT->getPointeeType();
+ if (isObjCIdType(pType))
+ return RHS;
+ // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS, true).
+ // Unfortunately, this API is part of Sema (which we don't have access
+ // to. Need to refactor. The following check is insufficient, since we
+ // need to make sure the class implements the protocol.
+ if (pType->isObjCInterfaceType())
+ return RHS;
+ }
+ }
// If the canonical type classes don't match.
if (LHSClass != RHSClass) {
- // ID is compatible with all qualified id types.
- if (LHS->isObjCQualifiedIdType()) {
- if (const PointerType *PT = RHS->getAsPointerType()) {
- QualType pType = PT->getPointeeType();
- if (isObjCIdType(pType))
- return LHS;
- // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS,
true).
- // Unfortunately, this API is part of Sema (which we don't have access
- // to. Need to refactor. The following check is insufficient, since we
- // need to make sure the class implements the protocol.
- if (pType->isObjCInterfaceType())
- return LHS;
- }
- }
- if (RHS->isObjCQualifiedIdType()) {
- if (const PointerType *PT = LHS->getAsPointerType()) {
- QualType pType = PT->getPointeeType();
- if (isObjCIdType(pType))
- return RHS;
- // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS,
true).
- // Unfortunately, this API is part of Sema (which we don't have access
- // to. Need to refactor. The following check is insufficient, since we
- // need to make sure the class implements the protocol.
- if (pType->isObjCInterfaceType())
- return RHS;
- }
- }
// C99 6.7.2.2p4: Each enumerated type shall be compatible with char,
// a signed integer type, or an unsigned integer type.
Added: cfe/trunk/test/SemaObjC/method-conflict.m
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-conflict.m?rev=60845&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/method-conflict.m (added)
+++ cfe/trunk/test/SemaObjC/method-conflict.m Wed Dec 10 14:07:25 2008
@@ -0,0 +1,53 @@
+// RUN: clang -fsyntax-only -verify %s
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
[EMAIL PROTECTED] NSInvocation, NSMethodSignature, NSCoder, NSString,
NSEnumerator;
[EMAIL PROTECTED] NSObject - (BOOL)isEqual:(id)object;
[EMAIL PROTECTED] @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
[EMAIL PROTECTED] @protocol NSMutableCopying -
(id)mutableCopyWithZone:(NSZone *)zone;
[EMAIL PROTECTED] @protocol NSCoding - (void)encodeWithCoder:(NSCoder
*)aCoder;
[EMAIL PROTECTED] @interface NSObject <NSObject> {
+}
[EMAIL PROTECTED] extern id NSAllocateObject(Class aClass, NSUInteger
extraBytes, NSZone *zone);
[EMAIL PROTECTED] NSValue : NSObject <NSCopying, NSCoding> -
(void)getValue:(void *)value;
[EMAIL PROTECTED] @class NSString;
+typedef struct _NSRange {
+}
+ NSRange;
[EMAIL PROTECTED] NSValue (NSValueRangeExtensions) + (NSValue
*)valueWithRange:(NSRange)range;
[EMAIL PROTECTED] @interface NSAttributedString : NSObject <NSCopying,
NSMutableCopying, NSCoding> - (NSString *)string;
[EMAIL PROTECTED] @interface NSMutableAttributedString : NSAttributedString -
(void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str;
[EMAIL PROTECTED] @class NSArray, NSDictionary, NSString, NSError;
[EMAIL PROTECTED] NSScanner : NSObject <NSCopying> - (NSString *)string;
[EMAIL PROTECTED] typedef struct {
+}
+ CSSM_FIELDGROUP, *CSSM_FIELDGROUP_PTR;
[EMAIL PROTECTED] XDUMLClassifier;
[EMAIL PROTECTED] XDUMLClassInterfaceCommons <XDUMLClassifier> @end
@protocol XDUMLImplementation;
[EMAIL PROTECTED] XDUMLElement <NSObject> - (NSArray *) ownedElements;
[EMAIL PROTECTED] @protocol XDUMLDataType;
[EMAIL PROTECTED] XDUMLNamedElement <XDUMLElement> - (NSString *) name;
[EMAIL PROTECTED] enum _XDSourceLanguage {
+XDSourceUnknown=0, XDSourceJava, XDSourceC, XDSourceCPP,
XDSourceObjectiveC };
+typedef NSUInteger XDSourceLanguage;
[EMAIL PROTECTED] XDSCClassifier <XDUMLClassInterfaceCommons> -
(XDSourceLanguage)language;
[EMAIL PROTECTED] @class XDSCDocController;
[EMAIL PROTECTED] XDSCDisplaySpecification : NSObject <NSCoding>{
+}
[EMAIL PROTECTED] @class XDSCOperation;
[EMAIL PROTECTED] XDSCClassFormatter : NSObject {
+}
++ (NSUInteger) compartmentsForClassifier: (id <XDUMLClassifier>) classifier
withSpecification: (XDSCDisplaySpecification *) displaySpec;
[EMAIL PROTECTED]
[EMAIL PROTECTED] NSString;
[EMAIL PROTECTED] XDSCClassFormatter
+
++ appendVisibility: (id <XDUMLNamedElement>) element withSpecification:
(XDSCDisplaySpecification *) displaySpec to: (NSMutableAttributedString *)
attributedString
+{
+}
+// FIXME: should we warn? (since the protocols are different). FWIW...GCC
doesn't currently.
++ (NSUInteger) compartmentsForClassifier: (id <XDSCClassifier>) classifier
withSpecification: (XDSCDisplaySpecification *) displaySpec {
+}
[EMAIL PROTECTED]
\ No newline at end of file
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits