Home | History | Annotate | Download | only in SemaObjC
      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
      7 typedef unsigned long NSUInteger;
      8 #else
      9 typedef unsigned int NSUInteger;
     10 #endif
     11 
     12 @class NSString;
     13 
     14 extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
     15 
     16 @class NSFastEnumerationState;
     17 
     18 @protocol NSFastEnumeration
     19 
     20 - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len;
     21 
     22 @end
     23 
     24 @interface NSNumber 
     25 + (NSNumber *)numberWithInt:(int)value;
     26 @end
     27 
     28 @interface NSArray <NSFastEnumeration>
     29 + (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
     30 @end
     31 
     32 
     33 int main() {
     34  NSArray *array = @[@"Hello", @"There", @"How Are You", [NSNumber numberWithInt:42]];
     35 
     36   for (id string in array)
     37     NSLog(@"%@\n", string);
     38 
     39   NSArray *array1 = @["Forgot"]; // expected-error {{string literal must be prefixed by '@' in a collection}}
     40 
     41   const char *blah;
     42   NSArray *array2 = @[blah]; // expected-error{{collection element of type 'const char *' is not an Objective-C object}}
     43 }
     44 
     45 // rdar://14303083
     46 id Test14303083() {
     47   id obj = @[ @"A", (@"B" @"C")];
     48   return @[ @"A", @"B" @"C"]; // expected-warning {{concatenated NSString literal for an NSArray expression - possibly missing a comma}}
     49 }
     50 id radar15147688() {
     51 #define R15147688_A @"hello"
     52 #define R15147688_B "world"
     53 #define CONCATSTR R15147688_A R15147688_B
     54   id x = @[ @"stuff", CONCATSTR ]; // no-warning
     55   x = @[ @"stuff", @"hello" "world"]; // expected-warning {{concatenated NSString literal for an NSArray expression}}
     56   return x;
     57 }
     58