Argyrios Kyrtzidis | 0d578a6 | 2012-05-15 19:17:49 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
Argyrios Kyrtzidis | 811ee0e | 2012-05-24 17:49:22 +0000 | [diff] [blame^] | 2 | // RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify |
Argyrios Kyrtzidis | 0d578a6 | 2012-05-15 19:17:49 +0000 | [diff] [blame] | 3 | // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result |
| 4 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result |
| 5 | |
| 6 | #define YES __objc_yes |
| 7 | #define NO __objc_no |
| 8 | |
| 9 | typedef long NSInteger; |
| 10 | typedef unsigned long NSUInteger; |
| 11 | typedef signed char BOOL; |
| 12 | #define nil ((void*) 0) |
| 13 | |
| 14 | #define INT_MIN (-__INT_MAX__ -1) |
| 15 | |
| 16 | @interface NSObject |
| 17 | + (id)alloc; |
| 18 | @end |
| 19 | |
| 20 | @interface NSNumber : NSObject |
| 21 | @end |
| 22 | |
| 23 | @interface NSNumber (NSNumberCreation) |
| 24 | - (id)initWithChar:(char)value; |
| 25 | - (id)initWithUnsignedChar:(unsigned char)value; |
| 26 | - (id)initWithShort:(short)value; |
| 27 | - (id)initWithUnsignedShort:(unsigned short)value; |
| 28 | - (id)initWithInt:(int)value; |
| 29 | - (id)initWithUnsignedInt:(unsigned int)value; |
| 30 | - (id)initWithLong:(long)value; |
| 31 | - (id)initWithUnsignedLong:(unsigned long)value; |
| 32 | - (id)initWithLongLong:(long long)value; |
| 33 | - (id)initWithUnsignedLongLong:(unsigned long long)value; |
| 34 | - (id)initWithFloat:(float)value; |
| 35 | - (id)initWithDouble:(double)value; |
| 36 | - (id)initWithBool:(BOOL)value; |
| 37 | - (id)initWithInteger:(NSInteger)value; |
| 38 | - (id)initWithUnsignedInteger:(NSUInteger)value; |
| 39 | |
| 40 | + (NSNumber *)numberWithChar:(char)value; |
| 41 | + (NSNumber *)numberWithUnsignedChar:(unsigned char)value; |
| 42 | + (NSNumber *)numberWithShort:(short)value; |
| 43 | + (NSNumber *)numberWithUnsignedShort:(unsigned short)value; |
| 44 | + (NSNumber *)numberWithInt:(int)value; |
| 45 | + (NSNumber *)numberWithUnsignedInt:(unsigned int)value; |
| 46 | + (NSNumber *)numberWithLong:(long)value; |
| 47 | + (NSNumber *)numberWithUnsignedLong:(unsigned long)value; |
| 48 | + (NSNumber *)numberWithLongLong:(long long)value; |
| 49 | + (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; |
| 50 | + (NSNumber *)numberWithFloat:(float)value; |
| 51 | + (NSNumber *)numberWithDouble:(double)value; |
| 52 | + (NSNumber *)numberWithBool:(BOOL)value; |
| 53 | + (NSNumber *)numberWithInteger:(NSInteger)value; |
| 54 | + (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; |
| 55 | @end |
| 56 | |
Argyrios Kyrtzidis | 7fe103c | 2012-05-15 22:22:10 +0000 | [diff] [blame] | 57 | enum { |
| 58 | NSASCIIStringEncoding = 1, |
| 59 | NSUTF8StringEncoding = 4, |
| 60 | NSUnicodeStringEncoding = 10 |
| 61 | }; |
| 62 | typedef NSUInteger NSStringEncoding; |
| 63 | |
| 64 | @interface NSString : NSObject |
| 65 | @end |
| 66 | |
| 67 | @interface NSString (NSStringExtensionMethods) |
| 68 | + (id)stringWithUTF8String:(const char *)nullTerminatedCString; |
| 69 | + (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc; |
| 70 | + (id)stringWithCString:(const char *)bytes; |
| 71 | @end |
| 72 | |
Argyrios Kyrtzidis | 0d578a6 | 2012-05-15 19:17:49 +0000 | [diff] [blame] | 73 | enum MyEnm { |
| 74 | ME_foo |
| 75 | }; |
| 76 | |
| 77 | void foo() { |
| 78 | [NSNumber numberWithInt:INT_MIN]; |
| 79 | bool cppb; |
| 80 | [NSNumber numberWithBool:cppb]; |
| 81 | MyEnm myenum; |
| 82 | [NSNumber numberWithInteger:myenum]; |
| 83 | [NSNumber numberWithInteger:ME_foo]; |
Argyrios Kyrtzidis | 811ee0e | 2012-05-24 17:49:22 +0000 | [diff] [blame^] | 84 | [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires a cast}} |
Argyrios Kyrtzidis | 0d578a6 | 2012-05-15 19:17:49 +0000 | [diff] [blame] | 85 | } |
Argyrios Kyrtzidis | 7fe103c | 2012-05-15 22:22:10 +0000 | [diff] [blame] | 86 | |
| 87 | void boxString() { |
| 88 | NSString *s = [NSString stringWithUTF8String:"box"]; |
| 89 | const char *cstr1; |
| 90 | char *cstr2; |
| 91 | s = [NSString stringWithUTF8String:cstr1]; |
| 92 | s = [NSString stringWithUTF8String:cstr2]; |
| 93 | s = [NSString stringWithCString:cstr1 encoding:NSASCIIStringEncoding]; |
| 94 | s = [NSString stringWithCString:cstr1 encoding:NSUTF8StringEncoding]; |
| 95 | s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding]; |
| 96 | NSStringEncoding encode; |
| 97 | s = [NSString stringWithCString:cstr1 encoding:encode]; |
| 98 | s = [NSString stringWithCString:cstr1]; |
Argyrios Kyrtzidis | 0773659 | 2012-05-16 00:21:21 +0000 | [diff] [blame] | 99 | |
| 100 | static const char strarr[] = "coolbox"; |
| 101 | s = [NSString stringWithUTF8String:strarr]; |
Argyrios Kyrtzidis | 7fe103c | 2012-05-15 22:22:10 +0000 | [diff] [blame] | 102 | } |