1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc// rdar://10111397 3*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -triple i386-apple-macosx10.9.0 -fobjc-runtime=macosx-fragile-10.9.0 -fobjc-subscripting-legacy-runtime -verify %s 4*f4a2713aSLionel Sambuc// rdar://15363492 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 7*f4a2713aSLionel Sambuctypedef unsigned long NSUInteger; 8*f4a2713aSLionel Sambuc#else 9*f4a2713aSLionel Sambuctypedef unsigned int NSUInteger; 10*f4a2713aSLionel Sambuc#endif 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc@class NSString; 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambucextern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc@class NSFastEnumerationState; 17*f4a2713aSLionel Sambuc 18*f4a2713aSLionel Sambuc@protocol NSFastEnumeration 19*f4a2713aSLionel Sambuc 20*f4a2713aSLionel Sambuc- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len; 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc@end 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc@interface NSNumber 25*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithInt:(int)value; 26*f4a2713aSLionel Sambuc@end 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc@interface NSArray <NSFastEnumeration> 29*f4a2713aSLionel Sambuc+ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; 30*f4a2713aSLionel Sambuc@end 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambuc 33*f4a2713aSLionel Sambucint main() { 34*f4a2713aSLionel Sambuc NSArray *array = @[@"Hello", @"There", @"How Are You", [NSNumber numberWithInt:42]]; 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc for (id string in array) 37*f4a2713aSLionel Sambuc NSLog(@"%@\n", string); 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambuc NSArray *array1 = @["Forgot"]; // expected-error {{string literal must be prefixed by '@' in a collection}} 40*f4a2713aSLionel Sambuc 41*f4a2713aSLionel Sambuc const char *blah; 42*f4a2713aSLionel Sambuc NSArray *array2 = @[blah]; // expected-error{{collection element of type 'const char *' is not an Objective-C object}} 43*f4a2713aSLionel Sambuc} 44*f4a2713aSLionel Sambuc 45*f4a2713aSLionel Sambuc// rdar://14303083 46*f4a2713aSLionel Sambucid Test14303083() { 47*f4a2713aSLionel Sambuc id obj = @[ @"A", (@"B" @"C")]; 48*f4a2713aSLionel Sambuc return @[ @"A", @"B" @"C"]; // expected-warning {{concatenated NSString literal for an NSArray expression - possibly missing a comma}} 49*f4a2713aSLionel Sambuc} 50*f4a2713aSLionel Sambucid radar15147688() { 51*f4a2713aSLionel Sambuc#define R15147688_A @"hello" 52*f4a2713aSLionel Sambuc#define R15147688_B "world" 53*f4a2713aSLionel Sambuc#define CONCATSTR R15147688_A R15147688_B 54*f4a2713aSLionel Sambuc id x = @[ @"stuff", CONCATSTR ]; // no-warning 55*f4a2713aSLionel Sambuc x = @[ @"stuff", @"hello" "world"]; // expected-warning {{concatenated NSString literal for an NSArray expression}} 56*f4a2713aSLionel Sambuc return x; 57*f4a2713aSLionel Sambuc} 58