xref: /llvm-project/clang/test/SemaObjC/method-typecheck-1.m (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2
3@interface A
4- (void) setMoo: (int) x;	//  expected-note {{previous definition is here}}
5- (int) setMoo1: (int) x;	//  expected-note {{previous definition is here}}
6- (int) setOk : (int) x : (double) d;
7@end
8
9@implementation A
10-(void) setMoo: (float) x {}	//  expected-warning {{conflicting parameter types in implementation of 'setMoo:': 'int' vs 'float'}}
11- (char) setMoo1: (int) x { return 0; }	//  expected-warning {{conflicting return type in implementation of 'setMoo1:': 'int' vs 'char'}}
12- (int) setOk : (int) x : (double) d { return 0; }
13@end
14
15
16
17@interface C
18+ (void) cMoo: (int) x;	//  expected-note 2 {{previous definition is here}}
19@end
20
21@implementation C
22+(float) cMoo:   // expected-warning {{conflicting return type in implementation of 'cMoo:': 'void' vs 'float'}}
23   (float) x { return 0; }	//  expected-warning {{conflicting parameter types in implementation of 'cMoo:': 'int' vs 'float'}}
24@end
25
26
27@interface A(CAT)
28- (void) setCat: (int) x;	// expected-note 2 {{previous definition is here}}
29+ (void) cCat: (int) x;	//  expected-note {{previous definition is here}}
30@end
31
32@implementation A(CAT)
33-(float) setCat:  // expected-warning {{conflicting return type in implementation of 'setCat:': 'void' vs 'float'}}
34(float) x { return 0; }	//  expected-warning {{conflicting parameter types in implementation of 'setCat:': 'int' vs 'float'}}
35+ (int) cCat: (int) x { return 0; }	//  expected-warning {{conflicting return type in implementation of 'cCat:': 'void' vs 'int'}}
36@end
37
38// test that when implementation implements method in a category, types match.
39@interface testObject {}
40@end
41
42@interface testObject(Category)
43- (float)returnCGFloat; // expected-note {{previous definition is here}}
44@end
45
46@implementation testObject
47- (double)returnCGFloat { // expected-warning {{conflicting return type in implementation of 'returnCGFloat': 'float' vs 'double'}}
48  return 0.0;
49}
50@end
51