70 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#define nil ((void *)0)5 6void checkNSDictionaryUnavailableDiagnostic(void) {7 id key;8 id value;9 id dict = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}}10}11 12@class NSDictionary; // expected-note {{forward declaration of class here}}13 14void checkNSDictionaryFDDiagnostic(void) {15 id key;16 id value;17 id dic = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}}18}19 20@interface NSNumber21+ (NSNumber *)numberWithChar:(char)value;22+ (NSNumber *)numberWithInt:(int)value;23@end24 25@protocol NSCopying @end26typedef unsigned long NSUInteger;27typedef long NSInteger;28 29@interface NSDictionary30+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;31- (void)setObject:(id)object forKeyedSubscript:(id)key;32- (id)objectForKeyedSubscript:(id)key;33@end34 35@interface NSString<NSCopying>36@end37 38@interface NSArray39- (id)objectAtIndexedSubscript:(NSInteger)index;40- (void)setObject:(id)object atIndexedSubscript:(NSInteger)index;41@end42 43void *pvoid;44int main(void) {45 NSDictionary *dict = @{ @"name":@666 };46 dict[@"name"] = @666;47 48 dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an Objective-C pointer}}49 50 [@{@"foo" : @"bar"} objectForKeyedSubscript:nil];51 (void)@{@"foo" : @"bar"}[nil];52 [@{@"foo" : @"bar"} objectForKeyedSubscript:pvoid];53 (void)@{@"foo" : @"bar"}[pvoid];54 55 [@{@"foo" : @"bar"} setObject:nil forKeyedSubscript:@"gorf"];56 @{@"foo" : @"bar"}[nil] = @"gorf";57 [@{@"foo" : @"bar"} setObject:pvoid forKeyedSubscript:@"gorf"];58 @{@"foo" : @"bar"}[pvoid] = @"gorf";59 60 return 0;61}62 63enum XXXYYYZZZType { XXXYYYZZZTypeAny }; // expected-note {{'XXXYYYZZZTypeAny' declared here}}64void foo(void) {65 NSDictionary *d = @{66 @"A" : @(XXXYYYZZZTypeA), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}67 @"F" : @(XXXYYYZZZTypeSomethingSomething), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}68 };69}70