xref: /aosp_15_r20/external/clang/test/SemaObjC/forward-class-1.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2*67e74705SXin Li
3*67e74705SXin Li@class FOO, BAR; // expected-note {{forward declaration of class here}}
4*67e74705SXin Li@class FOO, BAR;
5*67e74705SXin Li
6*67e74705SXin Li@interface INTF : FOO	// expected-error {{attempting to use the forward class 'FOO' as superclass of 'INTF'}}
7*67e74705SXin Li@end
8*67e74705SXin Li
9*67e74705SXin Li@interface FOO
10*67e74705SXin Li- (BAR*) Meth1;
11*67e74705SXin Li- (FOO*) Meth2;
12*67e74705SXin Li@end
13*67e74705SXin Li
14*67e74705SXin Li@interface INTF1 : FOO
15*67e74705SXin Li@end
16*67e74705SXin Li
17*67e74705SXin Li@interface INTF2 : INTF1 // expected-note {{previous definition is here}}
18*67e74705SXin Li@end
19*67e74705SXin Li
20*67e74705SXin Li
21*67e74705SXin Li@class INTF1, INTF2;
22*67e74705SXin Li
23*67e74705SXin Li@interface INTF2 : INTF1 // expected-error {{duplicate interface definition for class 'INTF2'}}
24*67e74705SXin Li@end
25*67e74705SXin Li
26*67e74705SXin Li// 2nd test of a forward class declaration matching a typedef name
27*67e74705SXin Li// referring to class object.
28*67e74705SXin Li// FIXME. This may become a negative test should we decide to make this an error.
29*67e74705SXin Li//
30*67e74705SXin Li@interface NSObject @end
31*67e74705SXin Li
32*67e74705SXin Li@protocol XCElementP @end
33*67e74705SXin Li
34*67e74705SXin Litypedef NSObject <XCElementP> XCElement; // expected-note {{previous definition is here}}
35*67e74705SXin Li
36*67e74705SXin Li@interface XCElementMainImp  {
37*67e74705SXin Li  XCElement * _editingElement;
38*67e74705SXin Li}
39*67e74705SXin Li@end
40*67e74705SXin Li
41*67e74705SXin Li@class XCElement; // expected-warning {{redefinition of forward class 'XCElement' of a typedef name of an object type is ignored}}
42*67e74705SXin Li
43*67e74705SXin Li@implementation XCElementMainImp
44*67e74705SXin Li- (XCElement *)editingElement  { return _editingElement;  }
45*67e74705SXin Li@end
46*67e74705SXin Li
47*67e74705SXin Li
48*67e74705SXin Li// rdar://9653341
49*67e74705SXin Li@class B; // expected-note {{forward declaration of class here}}
50*67e74705SXin Li@interface A : B {} // expected-error {{attempting to use the forward class 'B' as superclass of 'A'}}
51*67e74705SXin Li@end
52*67e74705SXin Li
53*67e74705SXin Li@interface B : A {}
54*67e74705SXin Li@end
55*67e74705SXin Li
56*67e74705SXin Li@implementation A @end
57*67e74705SXin Li@implementation B @end
58*67e74705SXin Li
59