1// RUN: %clang_cc1 -fsyntax-only -verify %s 2typedef _Bool BOOL; 3 4@interface NSNumber @end 5 6@interface NSNumber (NSNumberCreation) 7+ (NSNumber *)numberWithChar:(char)value; 8+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; 9+ (NSNumber *)numberWithShort:(short)value; 10+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; 11+ (NSNumber *)numberWithInt:(int)value; 12+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; 13+ (NSNumber *)numberWithLong:(long)value; 14+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; 15+ (NSNumber *)numberWithLongLong:(long long)value; 16+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; 17+ (NSNumber *)numberWithFloat:(float)value; 18+ (NSNumber *)numberWithDouble:(double)value; 19+ (int)numberWithBool:(BOOL)value; // expected-note 2 {{method returns unexpected type 'int' (should be an object type)}} 20@end 21 22@interface NSString 23+ (char)stringWithUTF8String:(const char *)value; // expected-note 2 {{method returns unexpected type 'char' (should be an object type)}} 24@end 25 26@interface NSArray 27@end 28 29@interface NSArray (NSArrayCreation) 30+ (id)arrayWithObjects:(const int [])objects // expected-note 2 {{first parameter has unexpected type 'const int *' (should be 'const id *')}} 31 count:(unsigned long)cnt; 32@end 33 34@interface NSDictionary 35+ (id)dictionaryWithObjects:(const id [])objects 36 forKeys:(const int [])keys // expected-note 2 {{second parameter has unexpected type 'const int *' (should be 'const id *')}} 37 count:(unsigned long)cnt; 38@end 39 40// All tests are doubled to make sure that a bad method is not saved 41// and then used un-checked. 42void test_sig() { 43 (void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}} 44 (void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}} 45 id array = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}} 46 id array2 = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}} 47 id dict = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}} 48 id dict2 = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}} 49 id str = @("hello"); // expected-error{{literal construction method 'stringWithUTF8String:' has incompatible signature}} 50 id str2 = @("hello"); // expected-error{{literal construction method 'stringWithUTF8String:' has incompatible signature}} 51} 52