blob: 48c5f5cc2cf2cbf094d9c6422a04390809f04ae2 [file] [log] [blame]
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001// 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*);
Stephen Lin93ab6bf2013-08-15 06:47:53 +000037// CHECK-LABEL: define weak_odr void @_Z5test2IiEvP14NSMutableArray
Ted Kremenekebcb57a2012-03-06 20:05:56 +000038// 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*);
Stephen Lin93ab6bf2013-08-15 06:47:53 +000047// CHECK-LABEL: define weak_odr void @_Z5test3IiEvP14NSMutableArray
Ted Kremenekebcb57a2012-03-06 20:05:56 +000048// CHECK: @objc_msgSend
49// CHECK: ret void
50