1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2
3@interface MyClass1 @end
4
5@protocol p1,p2,p3;
6
7@interface MyClass1 (Category1)  <p1> // expected-warning {{cannot find protocol definition for 'p1'}} expected-note {{previous definition is here}}
8@end
9
10@interface MyClass1 (Category1)  // expected-warning {{duplicate definition of category 'Category1' on interface 'MyClass1'}}
11@end
12
13@interface MyClass1 (Category3)
14@end
15
16@interface MyClass1 (Category4) @end // expected-note {{previous definition is here}}
17@interface MyClass1 (Category5) @end
18@interface MyClass1 (Category6) @end
19@interface MyClass1 (Category7) @end // expected-note {{previous definition is here}}
20@interface MyClass1 (Category8) @end // expected-note {{previous definition is here}}
21
22
23@interface MyClass1 (Category4) @end // expected-warning {{duplicate definition of category 'Category4' on interface 'MyClass1'}}
24@interface MyClass1 (Category7) @end // expected-warning {{duplicate definition of category 'Category7' on interface 'MyClass1'}}
25@interface MyClass1 (Category8) @end // expected-warning {{duplicate definition of category 'Category8' on interface 'MyClass1'}}
26
27
28@protocol p3 @end
29
30@interface MyClass1 (Category) <p2, p3> @end  // expected-warning {{cannot find protocol definition for 'p2'}}
31
32@interface UnknownClass  (Category) @end // expected-error {{cannot find interface declaration for 'UnknownClass'}}
33
34@class MyClass2; // expected-note{{forward declaration of class here}}
35
36@interface MyClass2  (Category) @end  // expected-error {{cannot define category for undefined class 'MyClass2'}}
37
38@interface XCRemoteComputerManager
39@end
40
41@interface XCRemoteComputerManager()
42@end
43
44@interface XCRemoteComputerManager()
45@end
46
47@interface XCRemoteComputerManager(x) // expected-note {{previous definition is here}}
48@end
49
50@interface XCRemoteComputerManager(x) // expected-warning {{duplicate definition of category 'x' on interface 'XCRemoteComputerManager'}}
51@end
52
53@implementation XCRemoteComputerManager
54@end
55
56@implementation XCRemoteComputerManager(x) // expected-note {{previous definition is here}}
57@end
58
59@implementation XCRemoteComputerManager(x) // expected-error {{reimplementation of category 'x' for class 'XCRemoteComputerManager'}}
60@end
61
62// <rdar://problem/7249233>
63
64@protocol MultipleCat_P
65-(void) im0; // expected-note {{method 'im0' declared here}}
66@end
67
68@interface MultipleCat_I @end // expected-note {{required for direct or indirect protocol 'MultipleCat_P'}}
69
70@interface MultipleCat_I()  @end
71
72@interface MultipleCat_I() <MultipleCat_P>  @end
73
74@implementation MultipleCat_I // expected-warning {{method 'im0' in protocol not implemented}}
75@end
76
77// <rdar://problem/7680391> - Handle nameless categories with no name that refer
78// to an undefined class
79@interface RDar7680391 () @end // expected-error{{cannot find interface declaration}}
80
81// <rdar://problem/8891119> - Handle @synthesize being used in conjunction
82// with explicitly declared accessor.
83@interface RDar8891119 {
84  id _name;
85}
86@end
87@interface RDar8891119 ()
88- (id)name;
89@end
90@interface RDar8891119 ()
91@property (copy) id name;
92@end
93@implementation RDar8891119
94@synthesize name = _name;
95@end
96
97// rdar://10968158
98@class I; // expected-note {{forward declaration}}
99@implementation I(cat) // expected-error{{cannot find interface declaration}}
100@end
101
102// <rdar://problem/11478173>
103@interface Unrelated
104- foo;
105@end
106
107@interface Blah (Blarg) // expected-error{{cannot find interface declaration for 'Blah'}}
108- foo;
109@end
110