OSDN Git Service

Add Go frontend, libgo library, and Go testsuite.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / objc-foreach-5.m
1 /* FIXME: Run this test with the GNU runtime as well.  */
2 /* { dg-do compile { target *-*-darwin* } } */
3 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
4
5 #include <objc/objc-api.h>
6 #import <Foundation/Foundation.h>
7
8 NSArray * createTestVictim(unsigned capacity) {
9     NSMutableArray * arr = [[NSMutableArray alloc] initWithCapacity:capacity];
10     int x = 0;
11
12     for(x = 0; x < capacity; x++) {
13         NSNumber * num = [NSNumber numberWithInteger:x];
14         [arr addObject:num];
15     }
16     
17     NSArray * immutableCopy = [arr copy];
18     [arr release];
19     
20     return immutableCopy;
21 }
22
23 void addStuffUp(NSArray * values) {
24     NSInteger accumulator = 0;
25 //    for (id item in values) {
26     id item;
27     for (item in values) {
28         accumulator += [item integerValue];
29     }
30 }
31
32 int main (int argc, char const* argv[]) {
33     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
34     NSArray * target = createTestVictim(10);
35     addStuffUp(target);
36     [pool release];
37     return 0;
38 }
39 /* { dg-final { scan-assembler "_addStuffUp:" } } */