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