diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-06-10 19:02:48 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-06-10 19:02:48 +0000 |
commit | 3d5764091d69f287dafd90a95a901a2829ea9d10 (patch) | |
tree | af06f421f75afc91edab66e8793b94afaf73ae24 /clang | |
parent | 6e43965fbc0dd7c7b0cdc72ae6138d51426d610d (diff) | |
download | bcm5719-llvm-3d5764091d69f287dafd90a95a901a2829ea9d10.tar.gz bcm5719-llvm-3d5764091d69f287dafd90a95a901a2829ea9d10.zip |
Objective-C. Don't ignore availability attribute when
doing Objective-C subscript access. // rdar://16842487
PR19682.
llvm-svn: 210565
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaPseudoObject.cpp | 5 | ||||
-rw-r--r-- | clang/test/SemaObjC/objc-container-subscripting-attr.m | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaPseudoObject.cpp b/clang/lib/Sema/SemaPseudoObject.cpp index eaed1e47e98..c649cbe38d1 100644 --- a/clang/lib/Sema/SemaPseudoObject.cpp +++ b/clang/lib/Sema/SemaPseudoObject.cpp @@ -1359,6 +1359,8 @@ ExprResult ObjCSubscriptOpBuilder::buildGet() { // Arguments. Expr *args[] = { Index }; assert(InstanceBase); + if (AtIndexGetter) + S.DiagnoseUseOfDecl(AtIndexGetter, GenericLoc); msg = S.BuildInstanceMessageImplicit(InstanceBase, receiverType, GenericLoc, AtIndexGetterSelector, AtIndexGetter, @@ -1375,7 +1377,8 @@ ExprResult ObjCSubscriptOpBuilder::buildSet(Expr *op, SourceLocation opcLoc, bool captureSetValueAsResult) { if (!findAtIndexSetter()) return ExprError(); - + if (AtIndexSetter) + S.DiagnoseUseOfDecl(AtIndexSetter, GenericLoc); QualType receiverType = InstanceBase->getType(); Expr *Index = InstanceKey; diff --git a/clang/test/SemaObjC/objc-container-subscripting-attr.m b/clang/test/SemaObjC/objc-container-subscripting-attr.m new file mode 100644 index 00000000000..17110c47576 --- /dev/null +++ b/clang/test/SemaObjC/objc-container-subscripting-attr.m @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s +// rdar://16842487 +// pr19682 + +@interface Subscriptable +- (id)objectForKeyedSubscript:(id)sub __attribute__((unavailable)); // expected-note 2 {{'objectForKeyedSubscript:' has been explicitly marked unavailable here}} +- (void)setObject:(id)object forKeyedSubscript:(id)key __attribute__((unavailable)); // expected-note {{'setObject:forKeyedSubscript:' has been explicitly marked unavailable here}} +@end + +id test(Subscriptable *obj) { + obj[obj] = obj; // expected-error {{'setObject:forKeyedSubscript:' is unavailable}} + return obj[obj]; // expected-error {{'objectForKeyedSubscript:' is unavailable}} +} + +id control(Subscriptable *obj) { + return [obj objectForKeyedSubscript:obj]; // expected-error {{'objectForKeyedSubscript:' is unavailable}} +} + |