OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [foreach-1.m] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 704 jeremybenn
/* Test basic Objective-C foreach syntax.  This tests iterations that
2
   do nothing.
3
*/
4
/* { dg-do run } */
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" } */
8
 
9
#include "../objc-obj-c++-shared/TestsuiteObject.m"
10
 
11
extern void abort (void);
12
/*
13
struct __objcFastEnumerationState
14
{
15
  unsigned long state;
16
  id            *itemsPtr;
17
  unsigned long *mutationsPtr;
18
  unsigned long extra[5];
19
};
20
*/
21
@interface TestsuiteObject (NSFastEnumeration)
22
- (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
23
                                     objects:(id *)stackbuf
24
                                       count:(unsigned int)len;
25
@end
26
 
27
int main (void)
28
{
29
  int test_variable = 0;
30
  int counter = 0;
31
  id array = nil;
32
  id object = nil;
33
 
34
  /* Test that 'for (object in array)' is recognized and that nothing
35
     happens if array is nil.  */
36
  for (object in array)
37
    test_variable = 8;
38
 
39
  if (test_variable == 8)
40
    abort ();
41
 
42
  if (object != nil)
43
    abort ();
44
 
45
  /* Test that if nothing is done, object is set to nil.  */
46
  object = [TestsuiteObject new];
47
 
48
  for (object in array)
49
    ;
50
 
51
  if (object != nil)
52
    abort ();
53
 
54
  /* Test that you can reference 'object' inside the body.  */
55
  for (object in array)
56
    object = nil;
57
 
58
  if (object != nil)
59
    abort ();
60
 
61
  /* Test that 'for (id element in array) is recognized (and works).  */
62
  for (id element in array)
63
    test_variable = 8;
64
 
65
  if (test_variable == 8)
66
    abort ();
67
 
68
  /* Test that you can reference 'object' inside the body.  */
69
  for (id element in array)
70
    element = nil;
71
 
72
  /* Test that C for loops still work.  */
73
  test_variable = 0;
74
 
75
  for (counter = 0; counter < 4; counter++)
76
    test_variable++;
77
 
78
  if (test_variable != 4)
79
    abort ();
80
 
81
  return 0;
82
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.