Debian Codegraph @

clang/test/SemaObjC/forward-class-1.m

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2
3 @class FOO, BAR; // expected-note {{forward declaration of class here}}
4 @class FOO, BAR;
5
6 @interface INTF : FOO // expected-error {{attempting to use the forward class 'FOO' as superclass of 'INTF'}}
7 @end
8
9 @interface FOO
10 - (BAR*) Meth1;
11 - (FOO*) Meth2;
12 @end
13
14 @interface INTF1 : FOO
15 @end
16
17 @interface INTF2 : INTF1 // expected-note {{previous definition is here}}
18 @end
19
20
21 @class INTF1, INTF2;
22
23 @interface INTF2 : INTF1 // expected-error {{duplicate interface definition for class 'INTF2'}}
24 @end
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
34 typedef NSObject <XCElementP> XCElement; // expected-note {{previous definition is here}}
35
36 @interface XCElementMainImp {
37 XCElement * _editingElement;
38 }
39 @end
40
41 @class XCElement; // expected-warning {{redefinition of forward class 'XCElement' of a typedef name of an object type is ignored}}
42
43 @implementation XCElementMainImp
44 - (XCElement *)editingElement { return _editingElement; }
45 @end
46
47
48 @class B; // expected-note {{forward declaration of class here}}
49 @interface A : B {} // expected-error {{attempting to use the forward class 'B' as superclass of 'A'}}
50 @end
51
52 @interface B : A {}
53 @end
54
55 @implementation A @end
56 @implementation B @end
57