1 // RUN: %clang_cc1 -fsyntax-only -verify %s
4 @interface NSNumber @end
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)}}
23 + (char)stringWithUTF8String:(const char *)value; // expected-note 2 {{method returns unexpected type 'char' (should be an object type)}}
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;
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;
40 // All tests are doubled to make sure that a bad method is not saved
41 // and then used un-checked.
42 const char *getStr(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}}