1// RUN: %clang_cc1 -fsyntax-only -verify %s 2// rdar://11062080 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 4// rdar://15363492 5 6#define nil ((void *)0) 7 8@interface NSNumber 9+ (NSNumber *)numberWithChar:(char)value; 10+ (NSNumber *)numberWithInt:(int)value; 11@end 12 13@protocol NSCopying @end 14typedef unsigned long NSUInteger; 15typedef long NSInteger; 16 17@interface NSDictionary 18+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt; 19- (void)setObject:(id)object forKeyedSubscript:(id)key; 20- (id)objectForKeyedSubscript:(id)key; 21@end 22 23@interface NSString<NSCopying> 24@end 25 26@interface NSArray 27- (id)objectAtIndexedSubscript:(NSInteger)index; 28- (void)setObject:(id)object atIndexedSubscript:(NSInteger)index; 29@end 30 31void *pvoid; 32int main() { 33 NSDictionary *dict = @{ @"name":@666 }; 34 dict[@"name"] = @666; 35 36 dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an Objective-C pointer}} 37 38 // rdar://18254621 39 [@{@"foo" : @"bar"} objectForKeyedSubscript:nil]; 40 (void)@{@"foo" : @"bar"}[nil]; 41 [@{@"foo" : @"bar"} objectForKeyedSubscript:pvoid]; 42 (void)@{@"foo" : @"bar"}[pvoid]; 43 44 [@{@"foo" : @"bar"} setObject:nil forKeyedSubscript:@"gorf"]; 45 @{@"foo" : @"bar"}[nil] = @"gorf"; 46 [@{@"foo" : @"bar"} setObject:pvoid forKeyedSubscript:@"gorf"]; 47 @{@"foo" : @"bar"}[pvoid] = @"gorf"; 48 49 return 0; 50} 51 52