1 | // RUN: %clang_cc1 -fsyntax-only -Wselector -verify -Wno-objc-root-class %s |
2 | // rdar://8851684 |
3 | |
4 | @interface Foo |
5 | - (void) foo; |
6 | - (void) bar; |
7 | @end |
8 | |
9 | @implementation Foo |
10 | - (void) bar |
11 | { |
12 | } |
13 | |
14 | - (void) foo |
15 | { |
16 | SEL a,b,c; |
17 | a = @selector(b1ar); |
18 | b = @selector(bar); |
19 | } |
20 | @end |
21 | |
22 | @interface I |
23 | - length; |
24 | @end |
25 | |
26 | SEL func() |
27 | { |
28 | return @selector(length); // expected-warning {{no method with selector 'length' is implemented in this translation unit}} |
29 | } |
30 | |
31 | // rdar://9545564 |
32 | @class MSPauseManager; |
33 | |
34 | @protocol MSPauseManagerDelegate |
35 | @optional |
36 | - (void)pauseManagerDidPause:(MSPauseManager *)manager; |
37 | - (int)respondsToSelector:(SEL)aSelector; |
38 | @end |
39 | |
40 | @interface MSPauseManager |
41 | { |
42 | id<MSPauseManagerDelegate> _delegate; |
43 | } |
44 | @end |
45 | |
46 | |
47 | @implementation MSPauseManager |
48 | - (id) Meth { |
49 | if ([_delegate respondsToSelector:@selector(pauseManagerDidPause:)]) |
50 | return 0; |
51 | return 0; |
52 | } |
53 | @end |
54 | |
55 | // rdar://12938616 |
56 | @class NSXPCConnection; |
57 | |
58 | @interface NSObject |
59 | @end |
60 | |
61 | @interface INTF : NSObject |
62 | { |
63 | NSXPCConnection *cnx; // Comes in as a parameter. |
64 | } |
65 | - (void) Meth; |
66 | @end |
67 | |
68 | extern SEL MySelector(SEL s); |
69 | |
70 | @implementation INTF |
71 | - (void) Meth { |
72 | if( [cnx respondsToSelector:MySelector(@selector( _setQueue: ))] ) |
73 | { |
74 | } |
75 | |
76 | if( [cnx respondsToSelector:@selector( _setQueueXX: )] ) // No warning here. |
77 | { |
78 | } |
79 | if( [cnx respondsToSelector:(@selector( _setQueueXX: ))] ) // No warning here. |
80 | { |
81 | } |
82 | } |
83 | @end |
84 | |
85 | // rdar://14007194 |
86 | @interface UxTechTest : NSObject |
87 | - (int) invalidate : (id)Arg; |
88 | + (int) C_invalidate : (int)arg; |
89 | @end |
90 | |
91 | @interface UxTechTest(CAT) |
92 | - (char) invalidate : (int)arg; |
93 | + (int) C_invalidate : (char)arg; |
94 | @end |
95 | |
96 | @interface NSPort : NSObject |
97 | - (double) invalidate : (void*)Arg1; |
98 | + (int) C_invalidate : (id*)arg; |
99 | @end |
100 | |
101 | |
102 | @interface USEText : NSPort |
103 | - (int) invalidate : (int)arg; |
104 | @end |
105 | |
106 | @implementation USEText |
107 | - (int) invalidate :(int) arg { return 0; } |
108 | @end |
109 | |
110 | @interface USETextSub : USEText |
111 | - (int) invalidate : (id)arg; |
112 | @end |
113 | |
114 | // rdar://16428638 |
115 | @interface I16428638 |
116 | - (int) compare: (I16428638 *) arg1; // commenting out this line avoids the warning |
117 | @end |
118 | |
119 | @interface J16428638 |
120 | - (int) compare: (J16428638 *) arg1; |
121 | @end |
122 | |
123 | @implementation J16428638 |
124 | - (void)method { |
125 | SEL s = @selector(compare:); // spurious warning |
126 | (void)s; |
127 | } |
128 | - (int) compare: (J16428638 *) arg1 { |
129 | return 0; |
130 | } |
131 | @end |
132 | |
133 | void test16428638() { |
134 | SEL s = @selector(compare:); |
135 | (void)s; |
136 | } |
137 | |
138 | // rdar://16607480 |
139 | @class NSString; |
140 | @interface SELCanary : NSObject |
141 | @property (readonly, nonatomic) NSString *name; |
142 | @property (nonatomic, getter = isHidden) char hidden; |
143 | @property (nonatomic, copy, getter = hasFish, setter = setFish:) NSString *ridiculousFish; |
144 | @end |
145 | |
146 | @implementation SELCanary |
147 | - (void) Meth { |
148 | SEL properties[] = { |
149 | @selector(name), |
150 | @selector(isHidden), |
151 | @selector(setHidden:), |
152 | @selector(hasFish), |
153 | @selector(setFish:) |
154 | }; |
155 | } |
156 | @end |
157 | |
158 | |