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