1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // 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 #if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
5 typedef unsigned long NSUInteger;
7 typedef unsigned int NSUInteger;
10 void checkNSArrayUnavailableDiagnostic(void) {
12 id arr = @[obj]; // expected-error {{definition of class NSArray must be available to use Objective-C array literals}}
15 @class NSArray; // expected-note {{forward declaration of class here}}
17 void checkNSArrayFDDiagnostic(void) {
19 id arr = @[obj]; // expected-error {{definition of class NSArray must be available to use Objective-C array literals}}
24 extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
26 @class NSFastEnumerationState;
28 @protocol NSFastEnumeration
30 - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len;
35 + (NSNumber *)numberWithInt:(int)value;
38 @interface NSArray <NSFastEnumeration>
39 + (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
44 NSArray *array = @[@"Hello", @"There", @"How Are You", [NSNumber numberWithInt:42]];
46 for (id string in array)
47 NSLog(@"%@\n", string);
49 NSArray *array1 = @["Forgot"]; // expected-error {{string literal must be prefixed by '@' in a collection}}
52 NSArray *array2 = @[blah]; // expected-error{{collection element of type 'const char *' is not an Objective-C object}}
55 id Test14303083(void) {
56 id obj = @[ @"A", (@"B" @"C")];
57 return @[ @"A", @"B" @"C"]; // expected-warning {{concatenated NSString literal for an NSArray expression - possibly missing a comma}}
59 id radar15147688(void) {
60 #define R15147688_A @"hello"
61 #define R15147688_B "world"
62 #define CONCATSTR R15147688_A R15147688_B
63 id x = @[ @"stuff", CONCATSTR ]; // no-warning
64 x = @[ @"stuff", @"hello" "world"]; // expected-warning {{concatenated NSString literal for an NSArray expression}}
68 enum XXXYYYZZZType { XXXYYYZZZTypeAny }; // expected-note {{'XXXYYYZZZTypeAny' declared here}}
71 @(XXXYYYZZZTypeA), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}
72 @(XXXYYYZZZTypeSomethingSomething) // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}