1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -emit-llvm %s -o %t 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambucvoid p(const char*, ...); 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc@interface NSArray 6*f4a2713aSLionel Sambuc+(NSArray*) arrayWithObjects: (id) first, ...; 7*f4a2713aSLionel Sambuc-(unsigned) count; 8*f4a2713aSLionel Sambuc@end 9*f4a2713aSLionel Sambuc@interface NSString 10*f4a2713aSLionel Sambuc-(const char*) cString; 11*f4a2713aSLionel Sambuc@end 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc#define S(n) @#n 14*f4a2713aSLionel Sambuc#define L1(n) S(n+0),S(n+1) 15*f4a2713aSLionel Sambuc#define L2(n) L1(n+0),L1(n+2) 16*f4a2713aSLionel Sambuc#define L3(n) L2(n+0),L2(n+4) 17*f4a2713aSLionel Sambuc#define L4(n) L3(n+0),L3(n+8) 18*f4a2713aSLionel Sambuc#define L5(n) L4(n+0),L4(n+16) 19*f4a2713aSLionel Sambuc#define L6(n) L5(n+0),L5(n+32) 20*f4a2713aSLionel Sambuc 21*f4a2713aSLionel Sambucvoid t0() { 22*f4a2713aSLionel Sambuc NSArray *array = [NSArray arrayWithObjects: L1(0), (void*)0]; 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc p("array.length: %d\n", [array count]); 25*f4a2713aSLionel Sambuc unsigned index = 0; 26*f4a2713aSLionel Sambuc for (NSString *i in array) { // expected-warning {{collection expression type 'NSArray *' may not respond}} 27*f4a2713aSLionel Sambuc p("element %d: %s\n", index++, [i cString]); 28*f4a2713aSLionel Sambuc } 29*f4a2713aSLionel Sambuc} 30*f4a2713aSLionel Sambuc 31*f4a2713aSLionel Sambucvoid t1() { 32*f4a2713aSLionel Sambuc NSArray *array = [NSArray arrayWithObjects: L6(0), (void*)0]; 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc p("array.length: %d\n", [array count]); 35*f4a2713aSLionel Sambuc unsigned index = 0; 36*f4a2713aSLionel Sambuc for (NSString *i in array) { // expected-warning {{collection expression type 'NSArray *' may not respond}} 37*f4a2713aSLionel Sambuc index++; 38*f4a2713aSLionel Sambuc if (index == 10) 39*f4a2713aSLionel Sambuc continue; 40*f4a2713aSLionel Sambuc p("element %d: %s\n", index, [i cString]); 41*f4a2713aSLionel Sambuc if (index == 55) 42*f4a2713aSLionel Sambuc break; 43*f4a2713aSLionel Sambuc } 44*f4a2713aSLionel Sambuc} 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc// rdar://problem/9027663 47*f4a2713aSLionel Sambucvoid t2(NSArray *array) { 48*f4a2713aSLionel Sambuc for (NSArray *array in array) { // expected-warning {{collection expression type 'NSArray *' may not respond}} 49*f4a2713aSLionel Sambuc } 50*f4a2713aSLionel Sambuc} 51