1// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -std=c++11 %s 2// rdar://9293227 3 4@class NSArray; 5 6void f(NSArray *a) { 7 id keys; 8 for (int i : a); // expected-error{{selector element type 'int' is not a valid object}} 9 for ((id)2 : a); // expected-error {{for range declaration must declare a variable}} \ 10 // expected-warning {{expression result unused}} 11 for (2 : a); // expected-error {{for range declaration must declare a variable}} \ 12 // expected-warning {{expression result unused}} 13 14 for (id thisKey : keys); 15} 16 17/* // rdar://9072298 */ 18@protocol NSObject @end 19 20@interface NSObject <NSObject> { 21 Class isa; 22} 23@end 24 25typedef struct { 26 unsigned long state; 27 id *itemsPtr; 28 unsigned long *mutationsPtr; 29 unsigned long extra[5]; 30} NSFastEnumerationState; 31 32@protocol NSFastEnumeration 33 34- (unsigned long)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(unsigned long)len; 35 36@end 37 38int main () 39{ 40 NSObject<NSFastEnumeration>* collection = 0; 41 for (id thing : collection) { } 42 43 id array; 44 for (int (^b)(void) : array) { 45 if (b() == 10000) { 46 return 1; 47 } 48 } 49 return 0; 50} 51 52/* rdar://problem/11068137 */ 53@interface Test2 54@property (assign) id prop; 55@end 56void test2(NSObject<NSFastEnumeration> *collection) { 57 Test2 *obj; 58 for (obj.prop : collection) { // expected-error {{for range declaration must declare a variable}} \ 59 // expected-warning {{property access result unused - getters should not be used for side effects}} 60 } 61} 62