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