forked from OSchip/llvm-project
Objective-C. Don't ignore availability attribute when
doing Objective-C subscript access. // rdar://16842487 PR19682. llvm-svn: 210565
This commit is contained in:
parent
6e43965fbc
commit
3d5764091d
|
@ -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;
|
||||
|
||||
|
|
|
@ -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}}
|
||||
}
|
||||
|
Loading…
Reference in New Issue