diff options
| author | John McCall <rjmccall@apple.com> | 2010-10-28 02:34:38 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-10-28 02:34:38 +0000 |
| commit | 071df46743b99ea40e2cc6d5ce0d044082dd9f75 (patch) | |
| tree | d61a77e60a979242a7edff3b946aab7eca22a011 /clang/test/SemaObjC | |
| parent | 15597538ae9c748204aa2eef5f3f65e44669340b (diff) | |
| download | bcm5719-llvm-071df46743b99ea40e2cc6d5ce0d044082dd9f75.tar.gz bcm5719-llvm-071df46743b99ea40e2cc6d5ce0d044082dd9f75.zip | |
Implement the newest status quo for method override checking. The idea now
is that we need more information to decide the exact conditions for whether
one ObjCObjectPointer is an acceptable return/parameter override for another,
so we're going to disable that entire class of warning for now. The
"forward developement" warning category, -Wmethod-signatures, can receive
unrestricted feature work, and when we're happy with how it acts, we'll
turn it on by default.
This is a pretty conservative change, and nobody's totally content with it.
llvm-svn: 117524
Diffstat (limited to 'clang/test/SemaObjC')
| -rw-r--r-- | clang/test/SemaObjC/class-conforming-protocol-2.m | 2 | ||||
| -rw-r--r-- | clang/test/SemaObjC/comptypes-a.m | 2 | ||||
| -rw-r--r-- | clang/test/SemaObjC/method-conflict-1.m | 65 | ||||
| -rw-r--r-- | clang/test/SemaObjC/method-conflict-2.m | 4 | ||||
| -rw-r--r-- | clang/test/SemaObjC/method-conflict.m | 2 | ||||
| -rw-r--r-- | clang/test/SemaObjC/method-def-1.m | 2 | ||||
| -rw-r--r-- | clang/test/SemaObjC/method-typecheck-3.m | 11 |
7 files changed, 68 insertions, 20 deletions
diff --git a/clang/test/SemaObjC/class-conforming-protocol-2.m b/clang/test/SemaObjC/class-conforming-protocol-2.m index 29e5810338e..a3bd0b1d239 100644 --- a/clang/test/SemaObjC/class-conforming-protocol-2.m +++ b/clang/test/SemaObjC/class-conforming-protocol-2.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s @protocol NSWindowDelegate @end diff --git a/clang/test/SemaObjC/comptypes-a.m b/clang/test/SemaObjC/comptypes-a.m index d7dddaad52d..8480f524dc7 100644 --- a/clang/test/SemaObjC/comptypes-a.m +++ b/clang/test/SemaObjC/comptypes-a.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s +// RUN: %clang_cc1 -fsyntax-only -Wmethod-signatures -verify -pedantic %s typedef signed char BOOL; typedef int NSInteger; diff --git a/clang/test/SemaObjC/method-conflict-1.m b/clang/test/SemaObjC/method-conflict-1.m index fb62e2ef354..3cf2c6b5a90 100644 --- a/clang/test/SemaObjC/method-conflict-1.m +++ b/clang/test/SemaObjC/method-conflict-1.m @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s + +// This test case tests the default behavior. + // rdar://7933061 @interface NSObject @end @@ -7,15 +10,14 @@ @interface MyClass : NSObject { } -- (void)myMethod:(NSArray *)object; // expected-note {{previous definition is here}} -- (void)myMethod1:(NSObject *)object; // expected-note {{previous definition is here}} +- (void)myMethod:(NSArray *)object; +- (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}} @end @implementation MyClass -// Warn about this contravariant use for now: -- (void)myMethod:(NSObject *)object { // expected-warning {{conflicting parameter types in implementation of 'myMethod:': 'NSArray *' vs 'NSObject *'}} +- (void)myMethod:(NSObject *)object { } -- (void)myMethod1:(NSArray *)object { // expected-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}} +- (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}} } @end @@ -24,13 +26,58 @@ @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}} +- (void)myMethod:(id <MyProtocol>)object; // broken-note {{previous definition is here}} +- (void)myMethod1:(id <MyProtocol>)object; // broken-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)myMethod:(MyClass *)object { // broken-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> *'}} +- (void)myMethod1:(MyClass<MyProtocol> *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<MyProtocol>' vs 'MyClass<MyProtocol> *'}} } @end + + + +@interface A @end +@interface B : A @end + +@interface Test1 {} +- (void) test1:(A*) object; // broken-note {{previous definition is here}} +- (void) test2:(B*) object; +@end + +@implementation Test1 +- (void) test1:(B*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}} +- (void) test2:(A*) object {} +@end + +// rdar://problem/8597621 wants id -> A* to be an exception +@interface Test2 {} +- (void) test1:(id) object; // broken-note {{previous definition is here}} +- (void) test2:(A*) object; +@end +@implementation Test2 +- (void) test1:(A*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}} +- (void) test2:(id) object {} +@end + +@interface Test3 {} +- (A*) test1; +- (B*) test2; // broken-note {{previous definition is here}} +@end + +@implementation Test3 +- (B*) test1 { return 0; } +- (A*) test2 { return 0; } // broken-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}} +@end + +// The particular case of overriding with an id return is white-listed. +@interface Test4 {} +- (id) test1; +- (A*) test2; +@end +@implementation Test4 +- (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987 +- (id) test2 { return 0; } +@end diff --git a/clang/test/SemaObjC/method-conflict-2.m b/clang/test/SemaObjC/method-conflict-2.m index fd472824559..7b5a08ad9ee 100644 --- a/clang/test/SemaObjC/method-conflict-2.m +++ b/clang/test/SemaObjC/method-conflict-2.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-objc-covariant-overrides -fsyntax-only -verify %s +// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s @interface A @end @interface B : A @end @@ -39,6 +39,6 @@ - (A*) test2; @end @implementation Test4 -- (A*) test1 { return 0; } +- (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987 - (id) test2 { return 0; } @end diff --git a/clang/test/SemaObjC/method-conflict.m b/clang/test/SemaObjC/method-conflict.m index ecdf1d88cab..4eb72906125 100644 --- a/clang/test/SemaObjC/method-conflict.m +++ b/clang/test/SemaObjC/method-conflict.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s typedef signed char BOOL; typedef unsigned int NSUInteger; diff --git a/clang/test/SemaObjC/method-def-1.m b/clang/test/SemaObjC/method-def-1.m index 7630ad0fbd2..bc7ea7bc449 100644 --- a/clang/test/SemaObjC/method-def-1.m +++ b/clang/test/SemaObjC/method-def-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s @interface foo - (int)meth; diff --git a/clang/test/SemaObjC/method-typecheck-3.m b/clang/test/SemaObjC/method-typecheck-3.m index 23036e65d51..1999b7d4770 100644 --- a/clang/test/SemaObjC/method-typecheck-3.m +++ b/clang/test/SemaObjC/method-typecheck-3.m @@ -1,8 +1,9 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s +@class B; @interface A -- (id)obj; // expected-note {{previous definition is here}} -- (A*)a; // expected-note {{previous definition is here}} +- (B*)obj; +- (B*)a; // expected-note {{previous definition is here}} - (void)takesA: (A*)a; // expected-note {{previous definition is here}} - (void)takesId: (id)a; // expected-note {{previous definition is here}} @end @@ -12,8 +13,8 @@ @end @implementation B -- (B*)obj {return self;} // expected-warning {{conflicting return type in implementation of 'obj'}} -- (B*)a { return self;} // expected-warning {{conflicting return type in implementation of 'a'}} +- (id)obj {return self;} // 'id' overrides are white-listed? +- (A*)a { return self;} // expected-warning {{conflicting return type in implementation of 'a'}} - (void)takesA: (B*)a // expected-warning {{conflicting parameter types in implementation of 'takesA:'}} {} - (void)takesId: (B*)a // expected-warning {{conflicting parameter types in implementation of 'takesId:'}} |

