[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaObjC / objc-container-subscripting-attr.m
blobda421cf679837ed5f5001d247a7397645b1ce41b
1 // RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
2 // pr19682
4 @interface Subscriptable
5 - (id)objectForKeyedSubscript:(id)sub __attribute__((unavailable)); // expected-note 2 {{'objectForKeyedSubscript:' has been explicitly marked unavailable here}}
6 - (void)setObject:(id)object forKeyedSubscript:(id)key __attribute__((unavailable)); // expected-note {{'setObject:forKeyedSubscript:' has been explicitly marked unavailable here}}
7 @end
9 id test(Subscriptable *obj) {
10   obj[obj] = obj;  // expected-error {{'setObject:forKeyedSubscript:' is unavailable}}
11   return obj[obj]; // expected-error {{'objectForKeyedSubscript:' is unavailable}}
14 id control(Subscriptable *obj) {
15   return [obj objectForKeyedSubscript:obj]; // expected-error {{'objectForKeyedSubscript:' is unavailable}}