Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Fariborz Jahanian | 4b6df3f | 2007-10-04 00:22:33 +0000 | [diff] [blame] | 2 | |
Chris Lattner | 9257db5 | 2009-04-12 08:46:44 +0000 | [diff] [blame] | 3 | @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 Jahanian | 894c57f | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 13 | |
| 14 | @protocol p1,p2,p3; |
| 15 | |
| 16 | @protocol p1; |
| 17 | |
| 18 | @protocol PROTO1 |
Chris Lattner | 9257db5 | 2009-04-12 08:46:44 +0000 | [diff] [blame] | 19 | @required |
| 20 | - (int) FooBar; |
| 21 | @optional |
| 22 | - (void) MyMethod1; |
| 23 | + (int) S; |
Fariborz Jahanian | 894c57f | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 24 | @end |
| 25 | |
Chris Lattner | 9257db5 | 2009-04-12 08:46:44 +0000 | [diff] [blame] | 26 | |
Chris Lattner | 58fe03b | 2009-04-12 08:43:13 +0000 | [diff] [blame] | 27 | @protocol PROTO2<p1> |
Fariborz Jahanian | 894c57f | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 28 | @end |
| 29 | |
| 30 | @protocol p1 @end |
| 31 | |
Chris Lattner | b8b96af | 2008-11-23 22:46:27 +0000 | [diff] [blame] | 32 | @protocol PROTO<p1> // expected-note {{previous definition is here}} |
Fariborz Jahanian | 894c57f | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 33 | @end |
| 34 | |
Fariborz Jahanian | e2573e5 | 2009-04-06 23:43:32 +0000 | [diff] [blame] | 35 | @protocol PROTO<p1> // expected-warning {{duplicate protocol definition of 'PROTO'}} |
Fariborz Jahanian | 894c57f | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 36 | @end |
| 37 | |
| 38 | @protocol PROTO3<p1, p1> |
| 39 | @end |
| 40 | |
| 41 | @protocol p2 <p1> |
| 42 | @end |
| 43 | |
Chris Lattner | 58fe03b | 2009-04-12 08:43:13 +0000 | [diff] [blame] | 44 | @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 Jahanian | 894c57f | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 52 | @end |
Chris Lattner | a2b4d65 | 2009-04-12 08:45:55 +0000 | [diff] [blame] | 53 | |
| 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 | |