blob: ca38f20fbd0179c6d15847ed9f6e5c8315faf256 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Fariborz Jahanian4b6df3f2007-10-04 00:22:33 +00002
Chris Lattner9257db52009-04-12 08:46:44 +00003@interface INTF1
4@required // expected-error {{directive may only be specified in protocols only}}
5- (int) FooBar;
6- (int) FooBar1;
7- (int) FooBar2;
8@optional // expected-error {{directive may only be specified in protocols only}}
9+ (int) C;
10
11- (int)I;
12@end
Fariborz Jahanian894c57f2007-09-21 15:40:54 +000013
14@protocol p1,p2,p3;
15
16@protocol p1;
17
18@protocol PROTO1
Chris Lattner9257db52009-04-12 08:46:44 +000019@required
20- (int) FooBar;
21@optional
22- (void) MyMethod1;
23+ (int) S;
Fariborz Jahanian894c57f2007-09-21 15:40:54 +000024@end
25
Chris Lattner9257db52009-04-12 08:46:44 +000026
Chris Lattner58fe03b2009-04-12 08:43:13 +000027@protocol PROTO2<p1>
Fariborz Jahanian894c57f2007-09-21 15:40:54 +000028@end
29
30@protocol p1 @end
31
Chris Lattnerb8b96af2008-11-23 22:46:27 +000032@protocol PROTO<p1> // expected-note {{previous definition is here}}
Fariborz Jahanian894c57f2007-09-21 15:40:54 +000033@end
34
Fariborz Jahaniane2573e52009-04-06 23:43:32 +000035@protocol PROTO<p1> // expected-warning {{duplicate protocol definition of 'PROTO'}}
Fariborz Jahanian894c57f2007-09-21 15:40:54 +000036@end
37
38@protocol PROTO3<p1, p1>
39@end
40
41@protocol p2 <p1>
42@end
43
Chris Lattner58fe03b2009-04-12 08:43:13 +000044@protocol PROTO4 <p1, p2, PROTO, PROTO3, p3>
45@end
46
47
48// rdar://6771034
49@protocol XX;
50@protocol YY <XX> // Use of declaration of XX here should not cause a warning.
51- zz;
Fariborz Jahanian894c57f2007-09-21 15:40:54 +000052@end
Chris Lattnera2b4d652009-04-12 08:45:55 +000053
54
55// Detect circular dependencies.
56@protocol B;
57@protocol C < B > // expected-note{{previous definition is here}}
58@end
59@protocol A < C >
60@end
61@protocol B < A > // expected-error{{protocol has circular dependency}}
62@end
63
Douglas Gregor59c451e2010-08-07 12:29:18 +000064@protocol P
65- (int)test:(int)param, ..; // expected-warning{{type specifier missing}} \
66 // expected-error{{expected ';' after method prototype}}
67@end