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 | // rdar://12519216 |
39 | // test that when implementation implements method in a category, types match. |
40 | @interface testObject {} |
41 | @end |
42 | |
43 | @interface testObject(Category) |
44 | - (float)returnCGFloat; // expected-note {{previous definition is here}} |
45 | @end |
46 | |
47 | @implementation testObject |
48 | - (double)returnCGFloat { // expected-warning {{conflicting return type in implementation of 'returnCGFloat': 'float' vs 'double'}} |
49 | return 0.0; |
50 | } |
51 | @end |
52 | |