blob: 85c6c875014b382302bb89e33440839e12259224 [file] [log] [blame]
Patrick Beardb2f68202012-04-06 18:12:22 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
Fariborz Jahanian4b6df3f2007-10-04 00:22:33 +00002
Douglas Gregorb3029962011-11-14 22:10:01 +00003@class FOO, BAR; // expected-note {{forward declaration of class here}}
Douglas Gregor0af55012011-12-16 03:12:41 +00004@class FOO, BAR;
Fariborz Jahanianbd51b872007-09-20 20:26:44 +00005
Fariborz Jahaniana8139732011-06-23 23:16:19 +00006@interface INTF : FOO // expected-error {{attempting to use the forward class 'FOO' as superclass of 'INTF'}}
Fariborz Jahanianbd51b872007-09-20 20:26:44 +00007@end
8
9@interface FOO
10- (BAR*) Meth1;
11- (FOO*) Meth2;
12@end
13
14@interface INTF1 : FOO
15@end
16
Chris Lattnerb8b96af2008-11-23 22:46:27 +000017@interface INTF2 : INTF1 // expected-note {{previous definition is here}}
Fariborz Jahanianbd51b872007-09-20 20:26:44 +000018@end
19
20
21@class INTF1, INTF2;
22
Chris Lattnerb8b96af2008-11-23 22:46:27 +000023@interface INTF2 : INTF1 // expected-error {{duplicate interface definition for class 'INTF2'}}
Fariborz Jahanianbd51b872007-09-20 20:26:44 +000024@end
Fariborz Jahaniancae27c52009-05-07 21:49:26 +000025
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 Jahaniane42670b2012-01-24 00:40:15 +000034typedef NSObject <XCElementP> XCElement; // expected-note {{previous definition is here}}
Fariborz Jahaniancae27c52009-05-07 21:49:26 +000035
36@interface XCElementMainImp {
37 XCElement * _editingElement;
38}
39@end
40
Fariborz Jahaniane42670b2012-01-24 00:40:15 +000041@class XCElement; // expected-warning {{redefinition of forward class 'XCElement' of a typedef name of an object type is ignored}}
Fariborz Jahaniancae27c52009-05-07 21:49:26 +000042
43@implementation XCElementMainImp
44- (XCElement *)editingElement { return _editingElement; }
45@end
46
47
Fariborz Jahaniana8139732011-06-23 23:16:19 +000048// rdar://9653341
Douglas Gregorb3029962011-11-14 22:10:01 +000049@class B; // expected-note {{forward declaration of class here}}
Fariborz Jahaniana8139732011-06-23 23:16:19 +000050@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