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 6*f4a2713aSLionel Sambuc@interface NSMutableArray 7*f4a2713aSLionel Sambuc- (id)objectAtIndexedSubscript:(size_t)index; 8*f4a2713aSLionel Sambuc- (void)setObject:(id)object atIndexedSubscript:(size_t)index; 9*f4a2713aSLionel Sambuc@end 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambucstruct S { 12*f4a2713aSLionel Sambuc operator unsigned int (); 13*f4a2713aSLionel Sambuc operator id (); 14*f4a2713aSLionel Sambuc}; 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc@interface NSMutableDictionary 17*f4a2713aSLionel Sambuc- (id)objectForKeyedSubscript:(id)key; 18*f4a2713aSLionel Sambuc- (void)setObject:(id)object forKeyedSubscript:(id)key; 19*f4a2713aSLionel Sambuc@end 20*f4a2713aSLionel Sambuc 21*f4a2713aSLionel Sambucint main() { 22*f4a2713aSLionel Sambuc NSMutableArray<P> * array; 23*f4a2713aSLionel Sambuc S s; 24*f4a2713aSLionel Sambuc id oldObject = array[(int)s]; 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc NSMutableDictionary<P> *dict; 27*f4a2713aSLionel Sambuc dict[(id)s] = oldObject; 28*f4a2713aSLionel Sambuc oldObject = dict[(id)s]; 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc} 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambuctemplate <class T> void test2(NSMutableArray *a) { 33*f4a2713aSLionel Sambuc a[10] = 0; 34*f4a2713aSLionel Sambuc} 35*f4a2713aSLionel Sambuctemplate void test2<int>(NSMutableArray*); 36*f4a2713aSLionel Sambuc// CHECK-LABEL: define weak_odr void @_Z5test2IiEvP14NSMutableArray 37*f4a2713aSLionel Sambuc// CHECK: @objc_msgSend 38*f4a2713aSLionel Sambuc// CHECK: ret void 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc 41*f4a2713aSLionel Sambuctemplate <class T> void test3(NSMutableArray *a) { 42*f4a2713aSLionel Sambuc a[sizeof(T)] = 0; 43*f4a2713aSLionel Sambuc} 44*f4a2713aSLionel Sambuc 45*f4a2713aSLionel Sambuctemplate void test3<int>(NSMutableArray*); 46*f4a2713aSLionel Sambuc// CHECK-LABEL: define weak_odr void @_Z5test3IiEvP14NSMutableArray 47*f4a2713aSLionel Sambuc// CHECK: @objc_msgSend 48*f4a2713aSLionel Sambuc// CHECK: ret void 49*f4a2713aSLionel Sambuc 50*f4a2713aSLionel Sambuc// CHECK-LABEL: define void @_Z11static_dataP14NSMutableArray 51*f4a2713aSLionel Sambucvoid static_data(NSMutableArray *array) { 52*f4a2713aSLionel Sambuc // CHECK: call i32 @__cxa_guard_acquire 53*f4a2713aSLionel Sambuc // CHECK: {{call i8*.*@objc_msgSend }} 54*f4a2713aSLionel Sambuc // CHECK: call void @__cxa_guard_release 55*f4a2713aSLionel Sambuc static id x = array[4]; 56*f4a2713aSLionel Sambuc // CHECK: ret void 57*f4a2713aSLionel Sambuc} 58