1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify %s 2*67e74705SXin Li// rdar://11062080 3*67e74705SXin Li// 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*67e74705SXin Li// rdar://15363492 5*67e74705SXin Li 6*67e74705SXin Li#define nil ((void *)0) 7*67e74705SXin Li 8*67e74705SXin Livoid checkNSDictionaryUnavailableDiagnostic() { 9*67e74705SXin Li id key; 10*67e74705SXin Li id value; 11*67e74705SXin Li id dict = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}} 12*67e74705SXin Li} 13*67e74705SXin Li 14*67e74705SXin Li@class NSDictionary; // expected-note {{forward declaration of class here}} 15*67e74705SXin Li 16*67e74705SXin Livoid checkNSDictionaryFDDiagnostic() { 17*67e74705SXin Li id key; 18*67e74705SXin Li id value; 19*67e74705SXin Li id dic = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}} 20*67e74705SXin Li} 21*67e74705SXin Li 22*67e74705SXin Li@interface NSNumber 23*67e74705SXin Li+ (NSNumber *)numberWithChar:(char)value; 24*67e74705SXin Li+ (NSNumber *)numberWithInt:(int)value; 25*67e74705SXin Li@end 26*67e74705SXin Li 27*67e74705SXin Li@protocol NSCopying @end 28*67e74705SXin Litypedef unsigned long NSUInteger; 29*67e74705SXin Litypedef long NSInteger; 30*67e74705SXin Li 31*67e74705SXin Li@interface NSDictionary 32*67e74705SXin Li+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt; 33*67e74705SXin Li- (void)setObject:(id)object forKeyedSubscript:(id)key; 34*67e74705SXin Li- (id)objectForKeyedSubscript:(id)key; 35*67e74705SXin Li@end 36*67e74705SXin Li 37*67e74705SXin Li@interface NSString<NSCopying> 38*67e74705SXin Li@end 39*67e74705SXin Li 40*67e74705SXin Li@interface NSArray 41*67e74705SXin Li- (id)objectAtIndexedSubscript:(NSInteger)index; 42*67e74705SXin Li- (void)setObject:(id)object atIndexedSubscript:(NSInteger)index; 43*67e74705SXin Li@end 44*67e74705SXin Li 45*67e74705SXin Livoid *pvoid; 46*67e74705SXin Liint main() { 47*67e74705SXin Li NSDictionary *dict = @{ @"name":@666 }; 48*67e74705SXin Li dict[@"name"] = @666; 49*67e74705SXin Li 50*67e74705SXin Li dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an Objective-C pointer}} 51*67e74705SXin Li 52*67e74705SXin Li // rdar://18254621 53*67e74705SXin Li [@{@"foo" : @"bar"} objectForKeyedSubscript:nil]; 54*67e74705SXin Li (void)@{@"foo" : @"bar"}[nil]; 55*67e74705SXin Li [@{@"foo" : @"bar"} objectForKeyedSubscript:pvoid]; 56*67e74705SXin Li (void)@{@"foo" : @"bar"}[pvoid]; 57*67e74705SXin Li 58*67e74705SXin Li [@{@"foo" : @"bar"} setObject:nil forKeyedSubscript:@"gorf"]; 59*67e74705SXin Li @{@"foo" : @"bar"}[nil] = @"gorf"; 60*67e74705SXin Li [@{@"foo" : @"bar"} setObject:pvoid forKeyedSubscript:@"gorf"]; 61*67e74705SXin Li @{@"foo" : @"bar"}[pvoid] = @"gorf"; 62*67e74705SXin Li 63*67e74705SXin Li return 0; 64*67e74705SXin Li} 65*67e74705SXin Li 66