1// RUN: rm -rf %t 2// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify 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 9typedef long NSInteger; 10typedef unsigned long NSUInteger; 11typedef 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 57enum { 58 NSASCIIStringEncoding = 1, 59 NSUTF8StringEncoding = 4, 60 NSUnicodeStringEncoding = 10 61}; 62typedef 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 73enum MyEnm { 74 ME_foo 75}; 76 77void foo() { 78 @INT_MIN; 79 bool cppb; 80 @(cppb); 81 MyEnm myenum; 82 @(myenum); 83 @(ME_foo); 84 [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires casting 'bool' to 'double'}} 85} 86 87void boxString() { 88 NSString *s = @"box"; 89 const char *cstr1; 90 char *cstr2; 91 s = @(cstr1); 92 s = @(cstr2); 93 s = @(cstr1); 94 s = @(cstr1); 95 s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding]; 96 NSStringEncoding encode; 97 s = [NSString stringWithCString:cstr1 encoding:encode]; 98 s = @(cstr1); 99 100 static const char strarr[] = "coolbox"; 101 s = @(strarr); 102} 103