xref: /aosp_15_r20/external/clang/test/SemaObjC/objc-container-subscripting-attr.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
2*67e74705SXin Li// rdar://16842487
3*67e74705SXin Li// pr19682
4*67e74705SXin Li
5*67e74705SXin Li@interface Subscriptable
6*67e74705SXin Li- (id)objectForKeyedSubscript:(id)sub __attribute__((unavailable)); // expected-note 2 {{'objectForKeyedSubscript:' has been explicitly marked unavailable here}}
7*67e74705SXin Li- (void)setObject:(id)object forKeyedSubscript:(id)key __attribute__((unavailable)); // expected-note {{'setObject:forKeyedSubscript:' has been explicitly marked unavailable here}}
8*67e74705SXin Li@end
9*67e74705SXin Li
10*67e74705SXin Liid test(Subscriptable *obj) {
11*67e74705SXin Li  obj[obj] = obj;  // expected-error {{'setObject:forKeyedSubscript:' is unavailable}}
12*67e74705SXin Li  return obj[obj]; // expected-error {{'objectForKeyedSubscript:' is unavailable}}
13*67e74705SXin Li}
14*67e74705SXin Li
15*67e74705SXin Liid control(Subscriptable *obj) {
16*67e74705SXin Li  return [obj objectForKeyedSubscript:obj]; // expected-error {{'objectForKeyedSubscript:' is unavailable}}
17*67e74705SXin Li}
18*67e74705SXin Li
19