Patrick Beard | b2f6820 | 2012-04-06 18:12:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
Fariborz Jahanian | 4b6df3f | 2007-10-04 00:22:33 +0000 | [diff] [blame] | 2 | |
Douglas Gregor | b302996 | 2011-11-14 22:10:01 +0000 | [diff] [blame] | 3 | @class FOO, BAR; // expected-note {{forward declaration of class here}} |
Douglas Gregor | 0af5501 | 2011-12-16 03:12:41 +0000 | [diff] [blame] | 4 | @class FOO, BAR; |
Fariborz Jahanian | bd51b87 | 2007-09-20 20:26:44 +0000 | [diff] [blame] | 5 | |
Fariborz Jahanian | a813973 | 2011-06-23 23:16:19 +0000 | [diff] [blame] | 6 | @interface INTF : FOO // expected-error {{attempting to use the forward class 'FOO' as superclass of 'INTF'}} |
Fariborz Jahanian | bd51b87 | 2007-09-20 20:26:44 +0000 | [diff] [blame] | 7 | @end |
| 8 | |
| 9 | @interface FOO |
| 10 | - (BAR*) Meth1; |
| 11 | - (FOO*) Meth2; |
| 12 | @end |
| 13 | |
| 14 | @interface INTF1 : FOO |
| 15 | @end |
| 16 | |
Chris Lattner | b8b96af | 2008-11-23 22:46:27 +0000 | [diff] [blame] | 17 | @interface INTF2 : INTF1 // expected-note {{previous definition is here}} |
Fariborz Jahanian | bd51b87 | 2007-09-20 20:26:44 +0000 | [diff] [blame] | 18 | @end |
| 19 | |
| 20 | |
| 21 | @class INTF1, INTF2; |
| 22 | |
Chris Lattner | b8b96af | 2008-11-23 22:46:27 +0000 | [diff] [blame] | 23 | @interface INTF2 : INTF1 // expected-error {{duplicate interface definition for class 'INTF2'}} |
Fariborz Jahanian | bd51b87 | 2007-09-20 20:26:44 +0000 | [diff] [blame] | 24 | @end |
Fariborz Jahanian | cae27c5 | 2009-05-07 21:49:26 +0000 | [diff] [blame] | 25 | |
| 26 | // 2nd test of a forward class declaration matching a typedef name |
| 27 | // referring to class object. |
| 28 | // FIXME. This may become a negative test should we decide to make this an error. |
| 29 | // |
| 30 | @interface NSObject @end |
| 31 | |
| 32 | @protocol XCElementP @end |
| 33 | |
Fariborz Jahanian | e42670b | 2012-01-24 00:40:15 +0000 | [diff] [blame] | 34 | typedef NSObject <XCElementP> XCElement; // expected-note {{previous definition is here}} |
Fariborz Jahanian | cae27c5 | 2009-05-07 21:49:26 +0000 | [diff] [blame] | 35 | |
| 36 | @interface XCElementMainImp { |
| 37 | XCElement * _editingElement; |
| 38 | } |
| 39 | @end |
| 40 | |
Fariborz Jahanian | e42670b | 2012-01-24 00:40:15 +0000 | [diff] [blame] | 41 | @class XCElement; // expected-warning {{redefinition of forward class 'XCElement' of a typedef name of an object type is ignored}} |
Fariborz Jahanian | cae27c5 | 2009-05-07 21:49:26 +0000 | [diff] [blame] | 42 | |
| 43 | @implementation XCElementMainImp |
| 44 | - (XCElement *)editingElement { return _editingElement; } |
| 45 | @end |
| 46 | |
| 47 | |
Fariborz Jahanian | a813973 | 2011-06-23 23:16:19 +0000 | [diff] [blame] | 48 | // rdar://9653341 |
Douglas Gregor | b302996 | 2011-11-14 22:10:01 +0000 | [diff] [blame] | 49 | @class B; // expected-note {{forward declaration of class here}} |
Fariborz Jahanian | a813973 | 2011-06-23 23:16:19 +0000 | [diff] [blame] | 50 | @interface A : B {} // expected-error {{attempting to use the forward class 'B' as superclass of 'A'}} |
| 51 | @end |
| 52 | |
| 53 | @interface B : A {} |
| 54 | @end |
| 55 | |
| 56 | @implementation A @end |
| 57 | @implementation B @end |
| 58 | |