1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s 2*f4a2713aSLionel Sambuc// RUN: grep -F '@objc_assign_ivar' %t | count 14 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuctypedef struct { 5*f4a2713aSLionel Sambuc id element; 6*f4a2713aSLionel Sambuc id elementArray[10]; 7*f4a2713aSLionel Sambuc __strong id cfElement; 8*f4a2713aSLionel Sambuc __strong id cfElementArray[10]; 9*f4a2713aSLionel Sambuc} struct_with_ids_t; 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc@interface NSString @end 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc@interface Foo { 15*f4a2713aSLionel Sambuc@public 16*f4a2713aSLionel Sambuc// assignments to any/all of these fields should generate objc_assign_ivar 17*f4a2713aSLionel Sambuc __strong id dict; 18*f4a2713aSLionel Sambuc __strong id dictArray[3]; 19*f4a2713aSLionel Sambuc id ivar; 20*f4a2713aSLionel Sambuc id array[10]; 21*f4a2713aSLionel Sambuc id nsobject; 22*f4a2713aSLionel Sambuc NSString *stringArray[10]; 23*f4a2713aSLionel Sambuc struct_with_ids_t inner; 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc Foo *obj[20]; 26*f4a2713aSLionel Sambuc short idx[5]; 27*f4a2713aSLionel Sambuc} 28*f4a2713aSLionel Sambuc@end 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc// The test cases 31*f4a2713aSLionel Sambucint IvarAssigns; 32*f4a2713aSLionel Sambucvoid *rhs = 0; 33*f4a2713aSLionel Sambuc#define ASSIGNTEST(expr, global) expr = rhs 34*f4a2713aSLionel Sambuc 35*f4a2713aSLionel Sambucvoid testIvars() { 36*f4a2713aSLionel Sambuc Foo *foo; 37*f4a2713aSLionel Sambuc ASSIGNTEST(foo->ivar, IvarAssigns); // objc_assign_ivar 38*f4a2713aSLionel Sambuc ASSIGNTEST(foo->dict, IvarAssigns); // objc_assign_ivar 39*f4a2713aSLionel Sambuc ASSIGNTEST(foo->dictArray[0], IvarAssigns); // objc_assign_ivar 40*f4a2713aSLionel Sambuc ASSIGNTEST(foo->array[0], IvarAssigns); // objc_assign_ivar 41*f4a2713aSLionel Sambuc ASSIGNTEST(foo->nsobject, IvarAssigns); // objc_assign_ivar 42*f4a2713aSLionel Sambuc ASSIGNTEST(foo->stringArray[0], IvarAssigns); // objc_assign_ivar 43*f4a2713aSLionel Sambuc ASSIGNTEST(foo->inner.element, IvarAssigns); // objc_assign_ivar 44*f4a2713aSLionel Sambuc ASSIGNTEST(foo->inner.elementArray[0], IvarAssigns); // objc_assign_ivar 45*f4a2713aSLionel Sambuc ASSIGNTEST(foo->inner.cfElement, IvarAssigns); // objc_assign_ivar 46*f4a2713aSLionel Sambuc ASSIGNTEST(foo->inner.cfElementArray[0], IvarAssigns); // objc_assign_ivar 47*f4a2713aSLionel Sambuc int counter=1; 48*f4a2713aSLionel Sambuc ASSIGNTEST(foo->obj[5], IvarAssigns); // objc_assign_ivar 49*f4a2713aSLionel Sambuc ASSIGNTEST(foo->obj[++counter], IvarAssigns); // objc_assign_ivar 50*f4a2713aSLionel Sambuc foo->idx[++counter] = 15; 51*f4a2713aSLionel Sambuc ASSIGNTEST(foo->obj[foo->idx[2]], IvarAssigns); // objc_assign_ivar 52*f4a2713aSLionel Sambuc} 53