blob: d782c784f1de742d62bfe4461c4ee1916402a939 [file] [log] [blame]
Patrick Beardb2f68202012-04-06 18:12:22 +00001// RUN: %clang_cc1 -fsyntax-only -Wselector -verify -Wno-objc-root-class %s
Fariborz Jahanian1e99a772011-02-04 23:30:23 +00002// 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;
Fariborz Jahanian37bccca2013-05-28 23:49:32 +000017 a = @selector(b1ar); // expected-warning {{creating selector for nonexistent method 'b1ar'}}
Fariborz Jahanian1e99a772011-02-04 23:30:23 +000018 b = @selector(bar);
19}
20@end
21
22@interface I
23- length;
24@end
25
26SEL func()
27{
Fariborz Jahanian37bccca2013-05-28 23:49:32 +000028 return @selector(length); // expected-warning {{creating selector for nonexistent method 'length'}}
Fariborz Jahanian1e99a772011-02-04 23:30:23 +000029}
Fariborz Jahanian4c91d892011-07-13 19:05:43 +000030
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
Fariborz Jahanianf11ccc12013-01-21 22:32:29 +000055// 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
68extern SEL MySelector(SEL s);
69
70@implementation INTF
71- (void) Meth {
Fariborz Jahanian37bccca2013-05-28 23:49:32 +000072 if( [cnx respondsToSelector:MySelector(@selector( _setQueue: ))] ) // expected-warning {{creating selector for nonexistent method '_setQueue:'}}
Fariborz Jahanianf11ccc12013-01-21 22:32:29 +000073 {
74 }
75
76 if( [cnx respondsToSelector:@selector( _setQueueXX: )] ) // No warning here.
77 {
78 }
Fariborz Jahanian48f3cc22013-01-22 18:35:43 +000079 if( [cnx respondsToSelector:(@selector( _setQueueXX: ))] ) // No warning here.
80 {
81 }
Fariborz Jahanianf11ccc12013-01-21 22:32:29 +000082}
83@end
Fariborz Jahanianf98c6882013-05-30 21:48:58 +000084
85// rdar://14007194
86@interface UxTechTest : NSObject
87- (int) invalidate : (id)Arg; // expected-warning {{multiple selectors named 'invalidate:' found}}
88+ (int) C_invalidate : (int)arg; // expected-warning {{multiple selectors named 'C_invalidate:' found}}
89@end
90
91@interface UxTechTest(CAT)
92- (char) invalidate : (int)arg; // expected-note {{also found}}
93+ (int) C_invalidate : (char)arg; // expected-note {{also found}}
94@end
95
96@interface NSPort : NSObject
97- (double) invalidate : (void*)Arg1; // expected-note {{also found}}
98+ (int) C_invalidate : (id*)arg; // expected-note {{also found}}
99@end
100
101
102@interface USEText : NSPort
103- (int) invalidate : (int)arg; // expected-note {{also found}}
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