xref: /llvm-project/clang/test/SemaObjC/class-protocol-method-match.m (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: %clang_cc1  -Woverriding-method-mismatch -fsyntax-only -verify -Wno-objc-root-class %s
2
3@protocol Bar
4@required
5- (bycopy id)bud; // expected-note {{previous declaration is here}}
6- (unsigned char) baz; // expected-note {{previous declaration is here}}
7- (char) ok;
8- (void) also_ok;
9@end
10
11@protocol Bar1
12@required
13- (unsigned char) baz; // expected-note {{previous declaration is here}}
14- (unsigned char) also_ok; // expected-note {{previous declaration is here}}
15- (void) ban : (int) arg, ...; // expected-note {{previous declaration is here}}
16@end
17
18@protocol Baz <Bar, Bar1>
19- (void) bar : (unsigned char)arg; // expected-note {{previous declaration is here}}
20- (void) ok;
21- (char) bak; // expected-note {{previous declaration is here}}
22@end
23
24@interface Foo <Baz>
25- (id)bud; // expected-warning {{conflicting distributed object modifiers on return type in declaration of 'bud'}}
26- (void) baz; // expected-warning 2 {{conflicting return type in declaration of 'baz': 'unsigned char' vs 'void'}}
27- (void) bar : (unsigned char*)arg; // expected-warning {{conflicting parameter types in declaration of 'bar:': 'unsigned char' vs 'unsigned char *'}}
28- (void) ok;
29- (void) also_ok; // expected-warning {{conflicting return type in declaration of 'also_ok': 'unsigned char' vs 'void'}}
30- (void) still_ok;
31- (void) ban : (int) arg; // expected-warning {{conflicting variadic declaration of method and its implementation}}
32@end
33
34@interface Foo()
35- (void) bak;
36@end
37
38@implementation Foo
39- (bycopy id)bud { return 0; }
40- (void) baz {}
41- (void) bar : (unsigned char*)arg {}
42- (void) ok {}
43- (void) also_ok {}
44- (void) still_ok {}
45- (void) ban : (int) arg {}
46- (void) bak {} // expected-warning {{conflicting return type in declaration of 'bak': 'char' vs 'void'}}
47@end
48