1 // RUN: %clang_cc1 -fsyntax-only -fblocks -verify -std=c++11 %s
7 for (int i : a); // expected-error{{selector element type 'int' is not a valid object}}
8 for ((id)2 : a); // expected-error {{for range declaration must declare a variable}}
9 for (2 : a); // expected-error {{for range declaration must declare a variable}}
11 for (id thisKey : keys);
13 for (auto thisKey : keys) { } // expected-warning{{'auto' deduced as 'id' in declaration of 'thisKey'}}
16 void for_init_stmt() {
17 for (id keys; id key : keys) {} // expected-warning{{extension}} expected-error{{not supported}}
19 template<typename T> void for_init_stmt_tmpl() {
20 for (T keys; id key : keys) {} // expected-warning{{extension}} expected-error{{not supported}}
22 template void for_init_stmt_tmpl<id>(); // expected-note {{in instantiation of}}
24 template<typename Collection>
25 void ft(Collection col) {
27 for (auto x : col) { }
30 template void ft(NSArray *);
32 @protocol NSObject @end
34 @interface NSObject <NSObject> {
42 unsigned long *mutationsPtr;
43 unsigned long extra[5];
44 } NSFastEnumerationState;
46 @protocol NSFastEnumeration
48 - (unsigned long)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(unsigned long)len;
54 NSObject<NSFastEnumeration>* collection = 0;
55 for (id thing : collection) { }
58 for (int (^b)(void) : array) {
67 @property (assign) id prop;
69 void test2(NSObject<NSFastEnumeration> *collection) {
71 for (obj.prop : collection) { // expected-error {{for range declaration must declare a variable}}
75 void testErrors(NSArray *array) {
78 for (fn x in array) { } // expected-error{{non-variable declaration in 'for' loop}}