brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 146df19 Raw
54 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify %s2typedef _Bool BOOL;3 4@interface NSNumber @end5 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@end21 22@interface NSString23+ (char)stringWithUTF8String:(const char *)value; // expected-note 2 {{method returns unexpected type 'char' (should be an object type)}}24@end25 26@interface NSArray27@end28 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@end33 34@interface NSDictionary35+ (id)dictionaryWithObjects:(const id [])objects36                    forKeys:(const int [])keys // expected-note 2 {{second parameter has unexpected type 'const int *' (should be 'const id *')}}37                      count:(unsigned long)cnt;38@end39 40// All tests are doubled to make sure that a bad method is not saved41// and then used un-checked.42const char *getStr(void);43 44void test_sig(void) {45  (void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}}46  (void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}}47  id array = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}}48  id array2 = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}}49  id dict = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}}50  id dict2 = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}}51  id str = @(getStr()); // expected-error{{literal construction method 'stringWithUTF8String:' has incompatible signature}}52  id str2 = @(getStr()); // expected-error{{literal construction method 'stringWithUTF8String:' has incompatible signature}}53}54