1// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s
2
3typedef unsigned int size_t;
4@protocol P @end
5@protocol NSCopying @end
6
7@interface NSMutableArray
8- (id)objectAtIndexedSubscript:(size_t)index;
9- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
10@end
11
12struct S {
13  operator unsigned int ();
14  operator id ();
15};
16
17@interface NSMutableDictionary
18- (id)objectForKeyedSubscript:(id<NSCopying>)key;
19- (void)setObject:(id)object forKeyedSubscript:(id<NSCopying>)key;
20@end
21
22int main() {
23  NSMutableArray<P> * array;
24  S s;
25  id oldObject = array[(int)s];
26
27  NSMutableDictionary<P> *dict;
28  dict[(id)s] = oldObject;
29  oldObject = dict[(id)s];
30
31}
32
33template <class T> void test2(NSMutableArray *a) {
34  a[10] = 0;
35}
36template void test2<int>(NSMutableArray*);
37// CHECK-LABEL: define weak_odr void @_Z5test2IiEvP14NSMutableArray
38// CHECK: @objc_msgSend
39// CHECK: ret void
40
41
42template <class T> void test3(NSMutableArray *a) {
43  a[sizeof(T)] = 0;
44}
45
46template void test3<int>(NSMutableArray*);
47// CHECK-LABEL: define weak_odr void @_Z5test3IiEvP14NSMutableArray
48// CHECK: @objc_msgSend
49// CHECK: ret void
50
51