brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · fc02a70 Raw
75 lines · plain
1// RUN: %clang_cc1  -fsyntax-only -verify %s2// RUN: %clang_cc1  -fsyntax-only -triple i386-apple-macosx10.9.0 -fobjc-runtime=macosx-fragile-10.9.0 -fobjc-subscripting-legacy-runtime -verify %s3 4#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_645typedef unsigned long NSUInteger;6#else7typedef unsigned int NSUInteger;8#endif9 10void checkNSArrayUnavailableDiagnostic(void) {11  id obj;12  id arr = @[obj]; // expected-error {{definition of class NSArray must be available to use Objective-C array literals}}13}14 15@class NSArray; // expected-note {{forward declaration of class here}}16 17void checkNSArrayFDDiagnostic(void) {18  id obj;19  id arr = @[obj]; // expected-error {{definition of class NSArray must be available to use Objective-C array literals}}20}21 22@class NSString;23 24extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));25 26@class NSFastEnumerationState;27 28@protocol NSFastEnumeration29 30- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len;31 32@end33 34@interface NSNumber 35+ (NSNumber *)numberWithInt:(int)value;36@end37 38@interface NSArray <NSFastEnumeration>39+ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;40@end41 42 43int main(void) {44 NSArray *array = @[@"Hello", @"There", @"How Are You", [NSNumber numberWithInt:42]];45 46  for (id string in array)47    NSLog(@"%@\n", string);48 49  NSArray *array1 = @["Forgot"]; // expected-error {{string literal must be prefixed by '@' in a collection}}50 51  const char *blah;52  NSArray *array2 = @[blah]; // expected-error{{collection element of type 'const char *' is not an Objective-C object}}53}54 55id 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}}58}59id radar15147688(void) {60#define R15147688_A @"hello"61#define R15147688_B "world"62#define CONCATSTR R15147688_A R15147688_B63  id x = @[ @"stuff", CONCATSTR ]; // no-warning64  x = @[ @"stuff", @"hello" "world"]; // expected-warning {{concatenated NSString literal for an NSArray expression}}65  return x;66}67 68enum XXXYYYZZZType { XXXYYYZZZTypeAny }; // expected-note {{'XXXYYYZZZTypeAny' declared here}}69void foo(void) {70  NSArray *array = @[71    @(XXXYYYZZZTypeA),                 // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}72    @(XXXYYYZZZTypeSomethingSomething) // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}73  ];74}75