Debian Codegraph @

clang/test/SemaObjC/property-category-4.m

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2
3 @interface IDELogNavigator
4 {
5 id selectedObjects;
6 }
7 @end
8
9 @interface IDELogNavigator (CAT)
10 @property (readwrite, retain) id selectedObjects; // expected-note {{property declared here}}
11 @property (readwrite, retain) id d_selectedObjects; // expected-note {{property declared here}}
12 @end
13
14 @implementation IDELogNavigator
15 @synthesize selectedObjects = _selectedObjects; // expected-error {{property declared in category 'CAT' cannot be implemented in class implementation}}
16 @dynamic d_selectedObjects; // expected-error {{property declared in category 'CAT' cannot be implemented in class implementation}}
17 @end
18
19 // Test1
20 @interface NSArray
21 - (int)count;
22 @end
23
24 @protocol MyCountable
25 @property (readonly) int count;
26 @end
27
28
29 @interface NSArray(Additions) <MyCountable>
30 @end
31
32 @implementation NSArray(Additions)
33 @end
34
35 // Test2
36 @protocol NSProtocol
37 - (int)count;
38 @end
39
40 @interface NSArray1 <NSProtocol>
41 @end
42
43 @interface NSArray1(Additions) <MyCountable>
44 @end
45
46 @implementation NSArray1(Additions)
47 @end
48
49 // Test3
50 @interface Super <NSProtocol>
51 @end
52
53 @interface NSArray2 : Super @end
54
55 @interface NSArray2(Additions) <MyCountable>
56 @end
57
58 @implementation NSArray2(Additions)
59 @end
60
61 // Test3
62 @interface Super1 <NSProtocol>
63 @property (readonly) int count;
64 @end
65
66 @protocol MyCountable1
67 @end
68
69 @interface NSArray3 : Super1 <MyCountable1>
70 @end
71
72 @implementation NSArray3
73 @end
74
75 // Test4
76 @interface I
77 @property int d1;
78 @end
79
80 @interface I(CAT)
81 @property int d1;
82 @end
83
84 @implementation I(CAT)
85 @end
86
87 // Test5
88 @interface C @end
89
90 @interface C (CAT)
91 - (int) p;
92 @end
93
94
95 @interface C (Category)
96 @property (readonly) int p; // no warning for this property - a getter is declared in another category
97 @property (readonly) int p1; // expected-note {{property declared here}}
98 @property (readonly) int p2; // no warning for this property - a getter is declared in this category
99 - (int) p2;
100 @end
101
102 @implementation C (Category) // expected-warning {{property 'p1' requires method 'p1' to be defined - use @dynamic or provide a method implementation in this category}}
103 @end
104
105 // Test6
106 @protocol MyProtocol
107 @property (readonly) float anotherFloat; // expected-note {{property declared here}}
108 @property (readonly) float Float; // no warning for this property - a getter is declared in this protocol
109 - (float) Float;
110 @end
111
112 @interface MyObject
113 { float anotherFloat; }
114 @end
115
116 @interface MyObject (CAT) <MyProtocol>
117 @end
118
119 @implementation MyObject (CAT) // expected-warning {{property 'anotherFloat' requires method 'anotherFloat' to be defined - use @dynamic or provide a method implementation in this category}}
120 @end
121