xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/objc-container-subscripting-3.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1  -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc// rdar://10904488
3*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambuc@interface Test
5*f4a2713aSLionel Sambuc- (int)objectAtIndexedSubscript:(int)index; // expected-note {{method 'objectAtIndexedSubscript:' declared here}}
6*f4a2713aSLionel Sambuc- (void)setObject:(int)object atIndexedSubscript:(int)index; // expected-note {{parameter of type 'int' is declared here}}
7*f4a2713aSLionel Sambuc@end
8*f4a2713aSLionel Sambuc
9*f4a2713aSLionel Sambuc@interface NSMutableDictionary
10*f4a2713aSLionel Sambuc- (int)objectForKeyedSubscript:(id)key; // expected-note {{method 'objectForKeyedSubscript:' declared here}}
11*f4a2713aSLionel Sambuc- (void)setObject:(int)object forKeyedSubscript:(id)key; // expected-note {{parameter of type 'int' is declared here}}
12*f4a2713aSLionel Sambuc@end
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambucint main() {
15*f4a2713aSLionel Sambuc   Test *array;
16*f4a2713aSLionel Sambuc   int i = array[10]; // expected-error {{method for accessing array element must have Objective-C object return type instead of 'int'}}
17*f4a2713aSLionel Sambuc   array[2] = i;     // expected-error {{cannot assign to this array because assigning method's 2nd parameter of type 'int' is not an Objective-C pointer type}}
18*f4a2713aSLionel Sambuc
19*f4a2713aSLionel Sambuc   NSMutableDictionary *dict;
20*f4a2713aSLionel Sambuc   id key, val;
21*f4a2713aSLionel Sambuc   val = dict[key]; // expected-error {{method for accessing dictionary element must have Objective-C object return type instead of 'int'}} \
22*f4a2713aSLionel Sambuc                    // expected-warning {{incompatible integer to pointer conversion assigning to 'id' from 'int'}}
23*f4a2713aSLionel Sambuc   dict[key] = val; // expected-error {{method object parameter type 'int' is not object type}}
24*f4a2713aSLionel Sambuc}
25*f4a2713aSLionel Sambuc
26