1 /* Test basic Objective-C foreach syntax. This tests warnings and errors. */
2 /* { dg-do compile } */
4 #import "../objc-obj-c++-shared/Object1.h"
5 #import "../objc-obj-c++-shared/next-mapping.h"
8 struct __objcFastEnumerationState
12 unsigned long *mutationsPtr;
13 unsigned long extra[5];
16 @interface Object (NSFastEnumeration)
17 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
18 objects:(id *)stackbuf
19 count:(unsigned int)len;
28 for (object in array) /* Ok */
31 for (object in nil) /* Ok */
34 for (object in) /* { dg-error "missing collection in fast enumeration" } */
37 for (object = nil in array) /* { dg-error "invalid iterating variable in fast enumeration" } */
40 for (object in [object enumerator]) /* Ok */
43 for (12 in array) /* { dg-error "invalid iterating variable in fast enumeration" } */
44 ; /* { dg-error "iterating variable in fast enumeration is not an object" } */
47 ; /* { dg-error "collection in fast enumeration is not an object" } */