1 // RUN: %clang_cc1 -fsyntax-only -verify %s
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
6 #define nil ((void *)0)
8 void checkNSDictionaryUnavailableDiagnostic() {
11 id dict = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}}
14 @class NSDictionary; // expected-note {{forward declaration of class here}}
16 void checkNSDictionaryFDDiagnostic() {
19 id dic = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}}
23 + (NSNumber *)numberWithChar:(char)value;
24 + (NSNumber *)numberWithInt:(int)value;
27 @protocol NSCopying @end
28 typedef unsigned long NSUInteger;
29 typedef long NSInteger;
31 @interface NSDictionary
32 + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
33 - (void)setObject:(id)object forKeyedSubscript:(id)key;
34 - (id)objectForKeyedSubscript:(id)key;
37 @interface NSString<NSCopying>
41 - (id)objectAtIndexedSubscript:(NSInteger)index;
42 - (void)setObject:(id)object atIndexedSubscript:(NSInteger)index;
47 NSDictionary *dict = @{ @"name":@666 };
50 dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an Objective-C pointer}}
53 [@{@"foo" : @"bar"} objectForKeyedSubscript:nil];
54 (void)@{@"foo" : @"bar"}[nil];
55 [@{@"foo" : @"bar"} objectForKeyedSubscript:pvoid];
56 (void)@{@"foo" : @"bar"}[pvoid];
58 [@{@"foo" : @"bar"} setObject:nil forKeyedSubscript:@"gorf"];
59 @{@"foo" : @"bar"}[nil] = @"gorf";
60 [@{@"foo" : @"bar"} setObject:pvoid forKeyedSubscript:@"gorf"];
61 @{@"foo" : @"bar"}[pvoid] = @"gorf";
66 enum XXXYYYZZZType { XXXYYYZZZTypeAny }; // expected-note {{'XXXYYYZZZTypeAny' declared here}}
69 @"A" : @(XXXYYYZZZTypeA), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}
70 @"F" : @(XXXYYYZZZTypeSomethingSomething), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}