Objective-C. Don't ignore availability attribute when

doing Objective-C subscript access. // rdar://16842487
PR19682.

llvm-svn: 210565
This commit is contained in:
Fariborz Jahanian 2014-06-10 19:02:48 +00:00
parent 6e43965fbc
commit 3d5764091d
2 changed files with 22 additions and 1 deletions

View File

@ -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;

View File

@ -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}}
}