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-additional-sources "../objc-obj-c++-shared/Object1.m" } */
8 /* { dg-options "-Wall" } */
10 #import "../objc-obj-c++-shared/Object1.h"
12 extern void abort (void);
14 struct __objcFastEnumerationState
18 unsigned long *mutationsPtr;
19 unsigned long extra[5];
22 @interface Object (NSFastEnumeration)
23 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
24 objects:(id *)stackbuf
25 count:(unsigned int)len;
30 int test_variable = 0;
35 /* Test that 'for (object in array)' is recognized and that nothing
36 happens if array is nil. */
40 if (test_variable == 8)
46 /* Test that if nothing is done, object is set to nil. */
47 object = [Object new];
55 /* Test that you can reference 'object' inside the body. */
62 /* Test that 'for (id element in array) is recognized (and works). */
63 for (id element in array)
66 if (test_variable == 8)
69 /* Test that you can reference 'object' inside the body. */
70 for (id element in array)
73 /* Test that C for loops still work. */
76 for (counter = 0; counter < 4; counter++)
79 if (test_variable != 4)