1 /* Test basic Objective-C foreach syntax. This tests iterations that
5 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
6 /* { dg-additional-sources "../objc-obj-c++-shared/Object1.m" } */
8 #import "../objc-obj-c++-shared/Object1.h"
10 extern void abort (void);
12 struct __objcFastEnumerationState
16 unsigned long *mutationsPtr;
17 unsigned long extra[5];
20 @interface Object (NSFastEnumeration)
21 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
22 objects:(id *)stackbuf
23 count:(unsigned int)len;
28 int test_variable = 0;
33 /* Test that 'for (object in array)' is recognized and that nothing
34 happens if array is nil. */
38 if (test_variable == 8)
44 /* Test that if nothing is done, object is set to nil. */
45 object = [Object new];
53 /* Test that you can reference 'object' inside the body. */
60 /* Test that 'for (id element in array) is recognized (and works). */
61 for (id element in array)
64 if (test_variable == 8)
67 /* Test that you can reference 'object' inside the body. */
68 for (id element in array)
71 /* Test that C for loops still work. */
74 for (counter = 0; counter < 4; counter++)
77 if (test_variable != 4)