diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-10 17:16:30 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-10 17:16:30 +0000 |
commit | 3c12dd7675cd8ea9bdc8d7a0763c4058fca5e8d7 (patch) | |
tree | 89d07ee5137dafab8640768f39fb0703e2dba39d /clang/test | |
parent | 9996c8fe018b2063b98ce4dd005304674c9370b4 (diff) | |
download | bcm5719-llvm-3c12dd7675cd8ea9bdc8d7a0763c4058fca5e8d7.tar.gz bcm5719-llvm-3c12dd7675cd8ea9bdc8d7a0763c4058fca5e8d7.zip |
objective-c: Using existing infrastructure for finding
overridden methods to diagnose their type mismatch.
This is a general solution for previous fixes
for // rdar://6191214 and // rdar://9352731
and removes lots of duplicate code.
llvm-svn: 137222
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaObjC/class-protocol-method-match.m | 50 | ||||
-rw-r--r-- | clang/test/SemaObjC/dist-object-modifiers.m | 4 | ||||
-rw-r--r-- | clang/test/SemaObjC/qualified-protocol-method-conflicts.m | 28 |
3 files changed, 33 insertions, 49 deletions
diff --git a/clang/test/SemaObjC/class-protocol-method-match.m b/clang/test/SemaObjC/class-protocol-method-match.m index 4022ce3aee5..04243e96775 100644 --- a/clang/test/SemaObjC/class-protocol-method-match.m +++ b/clang/test/SemaObjC/class-protocol-method-match.m @@ -1,64 +1,48 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -Woverriding-method-mismatch -fsyntax-only -verify %s // rdar://9352731 @protocol Bar @required -- (unsigned char) baz; // expected-note {{previous definition is here}} -- (char) ok; // expected-note {{previous definition is here}} +- (bycopy id)bud; // expected-note {{previous declaration is here}} +- (unsigned char) baz; // expected-note {{previous declaration is here}} +- (char) ok; - (void) also_ok; @end @protocol Bar1 @required -- (unsigned char) baz; -- (unsigned char) also_ok; +- (unsigned char) baz; // expected-note {{previous declaration is here}} +- (unsigned char) also_ok; // expected-note {{previous declaration is here}} - (void) ban : (int) arg, ...; // expected-note {{previous declaration is here}} @end @protocol Baz <Bar, Bar1> -- (void) bar : (unsigned char)arg; // expected-note {{previous definition is here}} -- (void) ok; // expected-warning {{conflicting return type in declaration of 'ok': 'char' vs 'void'}} -- (char) bak; // expected-note {{previous definition is here}} +- (void) bar : (unsigned char)arg; // expected-note {{previous declaration is here}} +- (void) ok; +- (char) bak; // expected-note {{previous declaration is here}} @end -@interface Foo <Baz> // expected-note {{class is declared here}} -- (void) baz; // expected-warning {{conflicting return type in declaration of 'baz': 'unsigned char' vs 'void'}} +@interface Foo <Baz> +- (id)bud; // expected-warning {{conflicting distributed object modifiers on return type in declaration of 'bud'}} +- (void) baz; // expected-warning 2 {{conflicting return type in declaration of 'baz': 'unsigned char' vs 'void'}} - (void) bar : (unsigned char*)arg; // expected-warning {{conflicting parameter types in declaration of 'bar:': 'unsigned char' vs 'unsigned char *'}} - (void) ok; -- (void) also_ok; +- (void) also_ok; // expected-warning {{conflicting return type in declaration of 'also_ok': 'unsigned char' vs 'void'}} - (void) still_ok; -- (void) ban : (int) arg; // expected-warning {{conflicting variadic declaration of method and its declaration}} +- (void) ban : (int) arg; // expected-warning {{conflicting variadic declaration of method and its implementation}} @end @interface Foo() -- (void) bak; // expected-warning {{conflicting return type in declaration of 'bak': 'char' vs 'void'}} +- (void) bak; @end @implementation Foo +- (bycopy id)bud { return 0; } - (void) baz {} - (void) bar : (unsigned char*)arg {} - (void) ok {} - (void) also_ok {} - (void) still_ok {} - (void) ban : (int) arg {} -- (void) bak {} -@end - -// rdar://6911214 -@protocol Xint --(void) setX: (int) arg0; // expected-note {{previous definition is here}} -+(void) setX: (int) arg0; // expected-note {{previous definition is here}} -@end - -@interface A <Xint> -@end - -@interface C : A --(void) setX: (C*) arg0; // expected-warning {{conflicting parameter types in declaration of 'setX:': 'int' vs 'C *'}} -+(void) setX: (C*) arg0; // expected-warning {{conflicting parameter types in declaration of 'setX:': 'int' vs 'C *'}} -@end - -@implementation C --(void) setX: (C*) arg0 {} -+(void) setX: (C*) arg0 {} +- (void) bak {} // expected-warning {{conflicting return type in declaration of 'bak': 'char' vs 'void'}} @end diff --git a/clang/test/SemaObjC/dist-object-modifiers.m b/clang/test/SemaObjC/dist-object-modifiers.m index 77e9938177a..98a9ce6cdc5 100644 --- a/clang/test/SemaObjC/dist-object-modifiers.m +++ b/clang/test/SemaObjC/dist-object-modifiers.m @@ -4,12 +4,12 @@ @protocol P - (bycopy id)serverPID; // expected-note {{previous declaration is here}} - (void)doStuff:(bycopy id)clientId; // expected-note {{previous declaration is here}} -- (bycopy id)Ok; // expected-note {{previous declaration is here}} +- (bycopy id)Ok; + (oneway id) stillMore : (byref id)Arg : (bycopy oneway id)Arg1; // expected-note 3 {{previous declaration is here}} @end @interface I <P> -- (id)Ok; // expected-warning {{conflicting distributed object modifiers on return type in declaration of 'Ok'}} +- (id)Ok; @end @implementation I diff --git a/clang/test/SemaObjC/qualified-protocol-method-conflicts.m b/clang/test/SemaObjC/qualified-protocol-method-conflicts.m index da83c8338c1..0cff3ff4684 100644 --- a/clang/test/SemaObjC/qualified-protocol-method-conflicts.m +++ b/clang/test/SemaObjC/qualified-protocol-method-conflicts.m @@ -1,39 +1,39 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -Woverriding-method-mismatch -fsyntax-only -verify %s // rdar://6191214 @protocol Xint --(void) setX: (int) arg0; // expected-note 3 {{previous definition is here}} -+(int) C; // expected-note 3 {{previous definition is here}} +-(void) setX: (int) arg0; // expected-note {{previous declaration is here}} ++(int) C; // expected-note {{previous declaration is here}} @end @protocol Xfloat --(void) setX: (float) arg0; // expected-warning 3 {{conflicting parameter types in declaration of 'setX:': 'int' vs 'float'}} -+(float) C; // expected-warning 3 {{conflicting return type in declaration of 'C': 'int' vs 'float'}} +-(void) setX: (float) arg0; // expected-note 2 {{previous declaration is here}} ++(float) C; // expected-note 2 {{previous declaration is here}} @end -@interface A <Xint, Xfloat> // expected-note {{class is declared here}} +@interface A <Xint, Xfloat> @end @implementation A --(void) setX: (int) arg0 { } -+(int) C {return 0; } +-(void) setX: (int) arg0 { } // expected-warning {{conflicting parameter types in declaration of 'setX:': 'float' vs 'int'}} ++(int) C {return 0; } // expected-warning {{conflicting return type in declaration of 'C': 'float' vs 'int'}} @end -@interface B <Xfloat, Xint> // expected-note {{class is declared here}} +@interface B <Xfloat, Xint> @end @implementation B --(void) setX: (float) arg0 { } -+ (float) C {return 0.0; } +-(void) setX: (float) arg0 { } // expected-warning {{conflicting parameter types in declaration of 'setX:': 'int' vs 'float'}} ++ (float) C {return 0.0; } // expected-warning {{conflicting return type in declaration of 'C': 'int' vs 'float'}} @end @protocol Xint_float<Xint, Xfloat> @end -@interface C<Xint_float> // expected-note {{class is declared here}} +@interface C<Xint_float> @end @implementation C --(void) setX: (int) arg0 { } -+ (int) C {return 0;} +-(void) setX: (int) arg0 { } // expected-warning {{conflicting parameter types in declaration of 'setX:': 'float' vs 'int'}} ++ (int) C {return 0;} // expected-warning {{conflicting return type in declaration of 'C': 'float' vs 'int'}} @end |