aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaDeclObjC.cpp9
-rw-r--r--test/SemaObjC/class-conforming-protocol-2.m8
-rw-r--r--test/SemaObjC/comptypes-a.m5
-rw-r--r--test/SemaObjC/method-conflict-1.m35
-rw-r--r--test/SemaObjC/method-conflict.m4
5 files changed, 47 insertions, 14 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 98c676b5cf..89ae18fc39 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -751,10 +751,8 @@ void Sema::WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
void Sema::WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethodDecl,
ObjCMethodDecl *IntfMethodDecl) {
- if (!Context.typesAreCompatible(IntfMethodDecl->getResultType(),
- ImpMethodDecl->getResultType()) &&
- !Context.QualifiedIdConformsQualifiedId(IntfMethodDecl->getResultType(),
- ImpMethodDecl->getResultType())) {
+ if (!Context.hasSameType(IntfMethodDecl->getResultType(),
+ ImpMethodDecl->getResultType())) {
Diag(ImpMethodDecl->getLocation(), diag::warn_conflicting_ret_types)
<< ImpMethodDecl->getDeclName() << IntfMethodDecl->getResultType()
<< ImpMethodDecl->getResultType();
@@ -766,8 +764,7 @@ void Sema::WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethodDecl,
IM != EM; ++IM, ++IF) {
QualType ParmDeclTy = (*IF)->getType().getUnqualifiedType();
QualType ParmImpTy = (*IM)->getType().getUnqualifiedType();
- if (Context.typesAreCompatible(ParmDeclTy, ParmImpTy) ||
- Context.QualifiedIdConformsQualifiedId(ParmDeclTy, ParmImpTy))
+ if (Context.hasSameType(ParmDeclTy, ParmImpTy))
continue;
Diag((*IM)->getLocation(), diag::warn_conflicting_param_types)
diff --git a/test/SemaObjC/class-conforming-protocol-2.m b/test/SemaObjC/class-conforming-protocol-2.m
index fcf9146a11..32305d14e1 100644
--- a/test/SemaObjC/class-conforming-protocol-2.m
+++ b/test/SemaObjC/class-conforming-protocol-2.m
@@ -3,8 +3,8 @@
@protocol NSWindowDelegate @end
@interface NSWindow
-- (void)setDelegate:(id <NSWindowDelegate>)anObject;
-- (id <NSWindowDelegate>) delegate;
+- (void)setDelegate:(id <NSWindowDelegate>)anObject; // expected-note {{previous definition is here}}
+- (id <NSWindowDelegate>) delegate; // expected-note {{previous definition is here}}
@end
@protocol IBStringsTableWindowDelegate <NSWindowDelegate>
@@ -14,9 +14,9 @@
@end
@implementation IBStringsTableWindow
-- (void)setDelegate:(id <IBStringsTableWindowDelegate>)delegate {
+- (void)setDelegate:(id <IBStringsTableWindowDelegate>)delegate { // expected-warning {{conflicting parameter types in implementation of 'setDelegate:'}}
}
-- (id <IBStringsTableWindowDelegate>)delegate {
+- (id <IBStringsTableWindowDelegate>)delegate { // expected-warning {{conflicting return type in implementation of 'delegate':}}
return 0;
}
@end
diff --git a/test/SemaObjC/comptypes-a.m b/test/SemaObjC/comptypes-a.m
index d48dfe4074..d7dddaad52 100644
--- a/test/SemaObjC/comptypes-a.m
+++ b/test/SemaObjC/comptypes-a.m
@@ -18,7 +18,8 @@ NSInteger codeAssistantCaseCompareItems(id<PBXCompletionItem> a, id<PBXCompletio
@interface TedWantsToVerifyObjCDoesTheRightThing
-- compareThis:(int)a withThat:(id)b; // expected-note {{previous definition is here}}
+- compareThis:(int)a withThat:(id)b; // expected-note {{previous definition is here}} \
+ // expected-note {{previous definition is here}}
@end
@@ -26,7 +27,7 @@ NSInteger codeAssistantCaseCompareItems(id<PBXCompletionItem> a, id<PBXCompletio
- compareThis:(id<PBXCompletionItem>)
a // expected-warning {{conflicting parameter types in implementation of 'compareThis:withThat:': 'int' vs 'id<PBXCompletionItem>'}}
- withThat:(id<PBXCompletionItem>)b {
+ withThat:(id<PBXCompletionItem>)b { // expected-warning {{conflicting parameter types in implementation of 'compareThis:withThat:': 'id' vs 'id<PBXCompletionItem>'}}
return self;
}
diff --git a/test/SemaObjC/method-conflict-1.m b/test/SemaObjC/method-conflict-1.m
new file mode 100644
index 0000000000..871eb9d049
--- /dev/null
+++ b/test/SemaObjC/method-conflict-1.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://7933061
+
+@interface NSObject @end
+
+@interface NSArray : NSObject @end
+
+@interface MyClass : NSObject {
+}
+- (void)myMethod:(NSArray *)object; // expected-note {{previous definition is here}}
+- (void)myMethod1:(NSObject *)object; // expected-note {{previous definition is here}}
+@end
+
+@implementation MyClass
+- (void)myMethod:(NSObject *)object { // expected-warning {{conflicting parameter types in implementation of 'myMethod:': 'NSArray *' vs 'NSObject *'}}
+}
+- (void)myMethod1:(NSArray *)object { // expected-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}}
+}
+@end
+
+
+@protocol MyProtocol @end
+
+@interface MyOtherClass : NSObject <MyProtocol> {
+}
+- (void)myMethod:(id <MyProtocol>)object; // expected-note {{previous definition is here}}
+- (void)myMethod1:(id <MyProtocol>)object; // expected-note {{previous definition is here}}
+@end
+
+@implementation MyOtherClass
+- (void)myMethod:(MyClass *)object { // expected-warning {{conflicting parameter types in implementation of 'myMethod:': 'id<MyProtocol>' vs 'MyClass *'}}
+}
+- (void)myMethod1:(MyClass<MyProtocol> *)object { // expected-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<MyProtocol>' vs 'MyClass<MyProtocol> *'}}
+}
+@end
diff --git a/test/SemaObjC/method-conflict.m b/test/SemaObjC/method-conflict.m
index 5dc886fb7f..ecdf1d88ca 100644
--- a/test/SemaObjC/method-conflict.m
+++ b/test/SemaObjC/method-conflict.m
@@ -40,7 +40,7 @@ typedef NSUInteger XDSourceLanguage;
@end @class XDSCOperation;
@interface XDSCClassFormatter : NSObject {
}
-+ (NSUInteger) compartmentsForClassifier: (id <XDUMLClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec;
++ (NSUInteger) compartmentsForClassifier: (id <XDUMLClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec; // expected-note {{previous definition is here}}
@end
@class NSString;
@implementation XDSCClassFormatter
@@ -49,7 +49,7 @@ typedef NSUInteger XDSourceLanguage;
{
return 0;
}
-+ (NSUInteger) compartmentsForClassifier: (id <XDSCClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec {
++ (NSUInteger) compartmentsForClassifier: (id <XDSCClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec { // expected-warning {{conflicting parameter types in implementation of 'compartmentsForClassifier:withSpecification:'}}
return 0;
}
@end