Debian Codegraph @

gcc/testsuite/objc.dg/objc-foreach-5.m

raw
1 /* FIXME: Run this test with the GNU runtime as well. */
2 /* { dg-do compile { target *-*-darwin* } } */
3 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
4 /* { dg-skip-if "No NeXT fast enum. pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
5 /* { dg-additional-options "-framework Foundation" { target { *-*-darwin* } } } */
6
7 #include "../objc-obj-c++-shared/F-NSArray.h"
8 #include "../objc-obj-c++-shared/F-NSAutoreleasePool.h"
9 #include "../objc-obj-c++-shared/F-NSValue.h"
10
11 NSArray * createTestVictim(unsigned capacity) {
12 NSMutableArray * arr = [[NSMutableArray alloc] initWithCapacity:capacity];
13 int x = 0;
14
15 for(x = 0; x < capacity; x++) {
16 NSNumber * num = [NSNumber numberWithInteger:x];
17 [arr addObject:num];
18 }
19
20 NSArray * immutableCopy = [arr copy];
21 [arr release];
22
23 return immutableCopy;
24 }
25
26 void addStuffUp(NSArray * values) {
27 NSInteger accumulator = 0;
28 // for (id item in values) {
29 id item;
30 for (item in values) {
31 accumulator += [item integerValue];
32 }
33 }
34
35 int main (int argc, char const* argv[]) {
36 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
37 NSArray * target = createTestVictim(10);
38 addStuffUp(target);
39 [pool release];
40 return 0;
41 }
42 /* { dg-final { scan-assembler "_addStuffUp:" } } */