1 /* Test basic Objective-C foreach syntax. This tests warnings and errors. */
2 /* { dg-do compile } */
4 #import "../objc-obj-c++-shared/TestsuiteObject.h"
10 struct __objcFastEnumerationState
14 unsigned long *mutationsPtr;
15 unsigned long extra[5];
18 @interface TestsuiteObject (NSFastEnumeration)
19 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
20 objects:(id *)stackbuf
21 count:(unsigned int)len;
23 - (Class) classEnumerator;
32 for (object in array) /* Ok */
35 for (object in nil) /* Ok */
38 for (object in) /* { dg-error "missing collection in fast enumeration" } */
41 for (object = nil in array) /* { dg-error "invalid iterating variable in fast enumeration" } */
44 for (object in [object enumerator]) /* Ok */
47 for (object in [object classEnumerator]) /* Ok */
50 for (12 in array) /* { dg-error "invalid iterating variable in fast enumeration" } */
51 ; /* { dg-error "iterating variable in fast enumeration is not an object" "" { target *-*-* } .-1 } */
53 for (object in 12) /* { dg-error "collection in fast enumeration is not an object" } */
56 for (object in invalid) /* { dg-error "collection in fast enumeration is not an object" } */
59 for (invalid in [object enumerator]) /* { dg-error "iterating variable in fast enumeration is not an object" } */