1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-protocol-method-implementation %s
2
3__attribute__((objc_root_class))
4@interface A
5@end
6
7@interface A (Cat)
8- (void)A_Cat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
9@end
10
11@implementation A
12- (void)A_Cat { // expected-error {{direct method was declared in a category but is implemented in the primary interface}}
13}
14@end
15
16__attribute__((objc_root_class))
17@interface B
18- (void)B_primary __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
19@end
20
21@interface B ()
22- (void)B_extension __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
23@end
24
25@interface B (Cat)
26- (void)B_Cat __attribute__((objc_direct));
27@end
28
29@interface B (OtherCat)
30- (void)B_OtherCat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
31@end
32
33@implementation B
34- (void)B_primary {
35}
36- (void)B_extension {
37}
38- (void)B_implOnly __attribute__((objc_direct)) { // expected-note {{previous declaration is here}}
39}
40@end
41
42@implementation B (Cat)
43- (void)B_primary { // expected-error {{direct method was declared in the primary interface but is implemented in a category}}
44}
45- (void)B_extension { // expected-error {{direct method was declared in an extension but is implemented in a different category}}
46}
47- (void)B_Cat {
48}
49- (void)B_OtherCat { // expected-error {{direct method was declared in a category but is implemented in a different category}}
50}
51- (void)B_implOnly __attribute__((objc_direct)) { // expected-error {{direct method declaration conflicts with previous direct declaration of method 'B_implOnly'}}
52}
53@end
54
55__attribute__((objc_root_class))
56@interface C
57- (void)C1 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
58- (void)C2;                              // expected-note {{previous declaration is here}}
59@end
60
61@interface C (Cat)
62- (void)C1;                              // expected-error {{method declaration conflicts with previous direct declaration of method 'C1'}}
63- (void)C2 __attribute__((objc_direct)); // expected-error {{direct method declaration conflicts with previous declaration of method 'C2'}}
64@end
65