diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2014-09-10 20:55:31 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-09-10 20:55:31 +0000 |
| commit | d13951ff2feefe5bda0065ffb799874e86bc36e1 (patch) | |
| tree | 83b7f227da92e3f18ba64019e23f76c87e8720fa | |
| parent | 7f0f17b3fb5aa9c43e5952724dfc23814c9cba29 (diff) | |
| download | bcm5719-llvm-d13951ff2feefe5bda0065ffb799874e86bc36e1.tar.gz bcm5719-llvm-d13951ff2feefe5bda0065ffb799874e86bc36e1.zip | |
Objective-C. Accept 'nil' as indexing argument to
dictionary literals since the API which implements
them accepts it too. // rdar://18254621
llvm-svn: 217543
| -rw-r--r-- | clang/lib/Sema/SemaPseudoObject.cpp | 3 | ||||
| -rw-r--r-- | clang/test/SemaObjC/objc-dictionary-literal.m | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaPseudoObject.cpp b/clang/lib/Sema/SemaPseudoObject.cpp index b81b60c802e..7bfe3337494 100644 --- a/clang/lib/Sema/SemaPseudoObject.cpp +++ b/clang/lib/Sema/SemaPseudoObject.cpp @@ -1022,7 +1022,8 @@ Sema::ObjCSubscriptKind // If we don't have a class type in C++, there's no way we can get an // expression of integral or enumeration type. const RecordType *RecordTy = T->getAs<RecordType>(); - if (!RecordTy && T->isObjCObjectPointerType()) + if (!RecordTy && + (T->isObjCObjectPointerType() || T->isVoidPointerType())) // All other scalar cases are assumed to be dictionary indexing which // caller handles, with diagnostics if needed. return OS_Dictionary; diff --git a/clang/test/SemaObjC/objc-dictionary-literal.m b/clang/test/SemaObjC/objc-dictionary-literal.m index 9d86d88bcbe..718658e8c9b 100644 --- a/clang/test/SemaObjC/objc-dictionary-literal.m +++ b/clang/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> @@ -31,6 +34,13 @@ int main() { 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"} setObject:nil forKeyedSubscript:@"gorf"]; + @{@"foo" : @"bar"}[nil] = @"gorf"; + return 0; } |

