Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | typedef _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; |
Jordy Rose | 3eda6fa | 2012-05-12 17:32:56 +0000 | [diff] [blame] | 19 | + (int)numberWithBool:(BOOL)value; // expected-note 2 {{method returns unexpected type 'int' (should be an object type)}} |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 20 | @end |
| 21 | |
Jordy Rose | 99446d9 | 2012-05-12 15:53:41 +0000 | [diff] [blame] | 22 | @interface NSString |
Jordy Rose | 3eda6fa | 2012-05-12 17:32:56 +0000 | [diff] [blame] | 23 | + (char)stringWithUTF8String:(const char *)value; // expected-note 2 {{method returns unexpected type 'char' (should be an object type)}} |
Jordy Rose | 99446d9 | 2012-05-12 15:53:41 +0000 | [diff] [blame] | 24 | @end |
| 25 | |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 26 | @interface NSArray |
| 27 | @end |
| 28 | |
| 29 | @interface NSArray (NSArrayCreation) |
Jordy Rose | 3eda6fa | 2012-05-12 17:32:56 +0000 | [diff] [blame] | 30 | + (id)arrayWithObjects:(const int [])objects // expected-note 2 {{first parameter has unexpected type 'const int *' (should be 'const id *')}} |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 31 | count:(unsigned long)cnt; |
| 32 | @end |
| 33 | |
| 34 | @interface NSDictionary |
| 35 | + (id)dictionaryWithObjects:(const id [])objects |
Jordy Rose | 3eda6fa | 2012-05-12 17:32:56 +0000 | [diff] [blame] | 36 | forKeys:(const int [])keys // expected-note 2 {{second parameter has unexpected type 'const int *' (should be 'const id *')}} |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 37 | count:(unsigned long)cnt; |
| 38 | @end |
| 39 | |
Jordy Rose | 3eda6fa | 2012-05-12 17:32:56 +0000 | [diff] [blame] | 40 | // All tests are doubled to make sure that a bad method is not saved |
| 41 | // and then used un-checked. |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 42 | void test_sig() { |
| 43 | (void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}} |
Jordy Rose | 3eda6fa | 2012-05-12 17:32:56 +0000 | [diff] [blame] | 44 | (void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}} |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 45 | id array = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}} |
Jordy Rose | 3eda6fa | 2012-05-12 17:32:56 +0000 | [diff] [blame] | 46 | id array2 = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}} |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 47 | id dict = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}} |
Jordy Rose | 3eda6fa | 2012-05-12 17:32:56 +0000 | [diff] [blame] | 48 | id dict2 = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}} |
Jordy Rose | 99446d9 | 2012-05-12 15:53:41 +0000 | [diff] [blame] | 49 | id str = @("hello"); // expected-error{{literal construction method 'stringWithUTF8String:' has incompatible signature}} |
Jordy Rose | 3eda6fa | 2012-05-12 17:32:56 +0000 | [diff] [blame] | 50 | id str2 = @("hello"); // expected-error{{literal construction method 'stringWithUTF8String:' has incompatible signature}} |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 51 | } |