2012-03-07 04:05:56 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
|
|
typedef _Bool BOOL;
|
|
|
|
|
|
|
|
@interface NSNumber @end
|
|
|
|
|
|
|
|
@interface NSNumber (NSNumberCreation)
|
|
|
|
+ (NSNumber *)numberWithChar:(char)value;
|
|
|
|
+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
|
|
|
|
+ (NSNumber *)numberWithShort:(short)value;
|
|
|
|
+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
|
|
|
|
+ (NSNumber *)numberWithInt:(int)value;
|
|
|
|
+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
|
|
|
|
+ (NSNumber *)numberWithLong:(long)value;
|
|
|
|
+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
|
|
|
|
+ (NSNumber *)numberWithLongLong:(long long)value;
|
|
|
|
+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
|
|
|
|
+ (NSNumber *)numberWithFloat:(float)value;
|
|
|
|
+ (NSNumber *)numberWithDouble:(double)value;
|
2012-05-13 01:32:56 +08:00
|
|
|
+ (int)numberWithBool:(BOOL)value; // expected-note 2 {{method returns unexpected type 'int' (should be an object type)}}
|
2012-03-07 04:05:56 +08:00
|
|
|
@end
|
|
|
|
|
2012-05-12 23:53:41 +08:00
|
|
|
@interface NSString
|
2012-05-13 01:32:56 +08:00
|
|
|
+ (char)stringWithUTF8String:(const char *)value; // expected-note 2 {{method returns unexpected type 'char' (should be an object type)}}
|
2012-05-12 23:53:41 +08:00
|
|
|
@end
|
|
|
|
|
2012-03-07 04:05:56 +08:00
|
|
|
@interface NSArray
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface NSArray (NSArrayCreation)
|
2012-05-13 01:32:56 +08:00
|
|
|
+ (id)arrayWithObjects:(const int [])objects // expected-note 2 {{first parameter has unexpected type 'const int *' (should be 'const id *')}}
|
2012-03-07 04:05:56 +08:00
|
|
|
count:(unsigned long)cnt;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface NSDictionary
|
|
|
|
+ (id)dictionaryWithObjects:(const id [])objects
|
2012-05-13 01:32:56 +08:00
|
|
|
forKeys:(const int [])keys // expected-note 2 {{second parameter has unexpected type 'const int *' (should be 'const id *')}}
|
2012-03-07 04:05:56 +08:00
|
|
|
count:(unsigned long)cnt;
|
|
|
|
@end
|
|
|
|
|
2012-05-13 01:32:56 +08:00
|
|
|
// All tests are doubled to make sure that a bad method is not saved
|
|
|
|
// and then used un-checked.
|
2019-03-08 12:45:37 +08:00
|
|
|
const char *getStr(void);
|
|
|
|
|
2012-03-07 04:05:56 +08:00
|
|
|
void test_sig() {
|
2012-05-13 01:32:56 +08:00
|
|
|
(void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}}
|
2012-03-07 04:05:56 +08:00
|
|
|
(void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}}
|
|
|
|
id array = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}}
|
2012-05-13 01:32:56 +08:00
|
|
|
id array2 = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}}
|
2012-03-07 04:05:56 +08:00
|
|
|
id dict = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}}
|
2012-05-13 01:32:56 +08:00
|
|
|
id dict2 = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}}
|
2019-03-08 12:45:37 +08:00
|
|
|
id str = @(getStr()); // expected-error{{literal construction method 'stringWithUTF8String:' has incompatible signature}}
|
|
|
|
id str2 = @(getStr()); // expected-error{{literal construction method 'stringWithUTF8String:' has incompatible signature}}
|
2012-03-07 04:05:56 +08:00
|
|
|
}
|