1 /* Test basic Objective-C foreach syntax. This tests iterations that
5 /* { dg-skip-if "No NeXT fast enum. pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
6 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
7 /* { dg-options "-Wall" } */
9 #include "../objc-obj-c++-shared/TestsuiteObject.m"
11 extern void abort (void);
13 struct __objcFastEnumerationState
17 unsigned long *mutationsPtr;
18 unsigned long extra[5];
21 @interface TestsuiteObject (NSFastEnumeration)
22 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
23 objects:(id *)stackbuf
24 count:(unsigned int)len;
29 int test_variable = 0;
34 /* Test that 'for (object in array)' is recognized and that nothing
35 happens if array is nil. */
39 if (test_variable == 8)
45 /* Test that if nothing is done, object is set to nil. */
46 object = [TestsuiteObject new];
54 /* Test that you can reference 'object' inside the body. */
61 /* Test that 'for (id element in array) is recognized (and works). */
62 for (id element in array)
65 if (test_variable == 8)
68 /* Test that you can reference 'object' inside the body. */
69 for (id element in array)
72 /* Test that C for loops still work. */
75 for (counter = 0; counter < 4; counter++)
78 if (test_variable != 4)