diff options
Diffstat (limited to 'test/SemaObjC/objc-dictionary-literal.m')
-rw-r--r-- | test/SemaObjC/objc-dictionary-literal.m | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/SemaObjC/objc-dictionary-literal.m b/test/SemaObjC/objc-dictionary-literal.m index 9d86d88bcbec..f9fd57f2dae2 100644 --- a/test/SemaObjC/objc-dictionary-literal.m +++ b/test/SemaObjC/objc-dictionary-literal.m @@ -3,6 +3,8 @@ // RUN: %clang_cc1 -fsyntax-only -triple i386-apple-macosx10.9.0 -fobjc-runtime=macosx-fragile-10.9.0 -fobjc-subscripting-legacy-runtime -verify %s // rdar://15363492 +#define nil ((void *)0) + @interface NSNumber + (NSNumber *)numberWithChar:(char)value; + (NSNumber *)numberWithInt:(int)value; @@ -15,6 +17,7 @@ typedef long NSInteger; @interface NSDictionary + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt; - (void)setObject:(id)object forKeyedSubscript:(id)key; +- (id)objectForKeyedSubscript:(id)key; @end @interface NSString<NSCopying> @@ -25,12 +28,24 @@ typedef long NSInteger; - (void)setObject:(id)object atIndexedSubscript:(NSInteger)index; @end +void *pvoid; int main() { NSDictionary *dict = @{ @"name":@666 }; dict[@"name"] = @666; dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an Objective-C pointer}} + // rdar://18254621 + [@{@"foo" : @"bar"} objectForKeyedSubscript:nil]; + (void)@{@"foo" : @"bar"}[nil]; + [@{@"foo" : @"bar"} objectForKeyedSubscript:pvoid]; + (void)@{@"foo" : @"bar"}[pvoid]; + + [@{@"foo" : @"bar"} setObject:nil forKeyedSubscript:@"gorf"]; + @{@"foo" : @"bar"}[nil] = @"gorf"; + [@{@"foo" : @"bar"} setObject:pvoid forKeyedSubscript:@"gorf"]; + @{@"foo" : @"bar"}[pvoid] = @"gorf"; + return 0; } |