1 /* Test basic Objective-C foreach syntax. This tests warnings and errors. */
2 /* FIXME: Run this test with the NeXT runtime as well. */
3 /* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
4 /* { dg-do compile } */
7 #include <objc/Object.h>
8 extern void abort (void);
10 struct __objcFastEnumerationState
14 unsigned long *mutationsPtr;
15 unsigned long extra[5];
18 @interface Object (NSFastEnumeration)
19 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
20 objects:(id *)stackbuf
21 count:(unsigned int)len;
30 for (object in array) /* Ok */
33 for (object in nil) /* Ok */
36 for (object in) /* { dg-error "missing collection in fast enumeration" } */
39 for (object = nil in array) /* { dg-error "invalid iterating variable in fast enumeration" } */
42 for (object in [object enumerator]) /* Ok */
45 for (12 in array) /* { dg-error "invalid iterating variable in fast enumeration" } */
46 ; /* { dg-error "iterating variable in fast enumeration is not an object" } */
49 ; /* { dg-error "collection in fast enumeration is not an object" } */