1// RUN: %clang_cc1 -fsyntax-only -verify %s 2// rdar://10111397 3// 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// rdar://15363492 5 6#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 7typedef unsigned long NSUInteger; 8#else 9typedef unsigned int NSUInteger; 10#endif 11 12void checkNSArrayUnavailableDiagnostic() { 13 id obj; 14 id arr = @[obj]; // expected-error {{definition of class NSArray must be available to use Objective-C array literals}} 15} 16 17@class NSArray; // expected-note {{forward declaration of class here}} 18 19void checkNSArrayFDDiagnostic() { 20 id obj; 21 id arr = @[obj]; // expected-error {{definition of class NSArray must be available to use Objective-C array literals}} 22} 23 24@class NSString; 25 26extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); 27 28@class NSFastEnumerationState; 29 30@protocol NSFastEnumeration 31 32- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len; 33 34@end 35 36@interface NSNumber 37+ (NSNumber *)numberWithInt:(int)value; 38@end 39 40@interface NSArray <NSFastEnumeration> 41+ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; 42@end 43 44 45int main() { 46 NSArray *array = @[@"Hello", @"There", @"How Are You", [NSNumber numberWithInt:42]]; 47 48 for (id string in array) 49 NSLog(@"%@\n", string); 50 51 NSArray *array1 = @["Forgot"]; // expected-error {{string literal must be prefixed by '@' in a collection}} 52 53 const char *blah; 54 NSArray *array2 = @[blah]; // expected-error{{collection element of type 'const char *' is not an Objective-C object}} 55} 56 57// rdar://14303083 58id Test14303083() { 59 id obj = @[ @"A", (@"B" @"C")]; 60 return @[ @"A", @"B" @"C"]; // expected-warning {{concatenated NSString literal for an NSArray expression - possibly missing a comma}} 61} 62id radar15147688() { 63#define R15147688_A @"hello" 64#define R15147688_B "world" 65#define CONCATSTR R15147688_A R15147688_B 66 id x = @[ @"stuff", CONCATSTR ]; // no-warning 67 x = @[ @"stuff", @"hello" "world"]; // expected-warning {{concatenated NSString literal for an NSArray expression}} 68 return x; 69} 70