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 #define nil ((void *)0)
6 void checkNSDictionaryUnavailableDiagnostic(void) {
9 id dict = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}}
12 @class NSDictionary; // expected-note {{forward declaration of class here}}
14 void checkNSDictionaryFDDiagnostic(void) {
17 id dic = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}}
21 + (NSNumber *)numberWithChar:(char)value;
22 + (NSNumber *)numberWithInt:(int)value;
25 @protocol NSCopying @end
26 typedef unsigned long NSUInteger;
27 typedef long NSInteger;
29 @interface NSDictionary
30 + (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;
35 @interface NSString<NSCopying>
39 - (id)objectAtIndexedSubscript:(NSInteger)index;
40 - (void)setObject:(id)object atIndexedSubscript:(NSInteger)index;
45 NSDictionary *dict = @{ @"name":@666 };
48 dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an Objective-C pointer}}
50 [@{@"foo" : @"bar"} objectForKeyedSubscript:nil];
51 (void)@{@"foo" : @"bar"}[nil];
52 [@{@"foo" : @"bar"} objectForKeyedSubscript:pvoid];
53 (void)@{@"foo" : @"bar"}[pvoid];
55 [@{@"foo" : @"bar"} setObject:nil forKeyedSubscript:@"gorf"];
56 @{@"foo" : @"bar"}[nil] = @"gorf";
57 [@{@"foo" : @"bar"} setObject:pvoid forKeyedSubscript:@"gorf"];
58 @{@"foo" : @"bar"}[pvoid] = @"gorf";
63 enum XXXYYYZZZType { XXXYYYZZZTypeAny }; // expected-note {{'XXXYYYZZZTypeAny' declared here}}
66 @"A" : @(XXXYYYZZZTypeA), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}
67 @"F" : @(XXXYYYZZZTypeSomethingSomething), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}