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

Subversion Repositories openrisc

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

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 warnings and errors.  */
2
/* { dg-do compile } */
3
 
4
#import "../objc-obj-c++-shared/TestsuiteObject.h"
5
#import <objc/objc.h>
6
#undef  nil
7
#define nil ((id)0)
8
 
9
/*
10
struct __objcFastEnumerationState
11
{
12
  unsigned long state;
13
  id            *itemsPtr;
14
  unsigned long *mutationsPtr;
15
  unsigned long extra[5];
16
};
17
*/
18
@interface TestsuiteObject (NSFastEnumeration)
19
- (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
20
                                     objects:(id *)stackbuf
21
                                       count:(unsigned int)len;
22
- (id) enumerator;
23
- (Class) classEnumerator;
24
@end
25
 
26
int main (void)
27
{
28
  id array = nil;
29
  id object = nil;
30
  id *invalid = 0;
31
 
32
  for (object in array) /* Ok */
33
    ;
34
 
35
  for (object in nil) /* Ok */
36
    ;
37
 
38
  for (object in) /* { dg-error "missing collection in fast enumeration" } */
39
    ;
40
 
41
  for (object = nil in array) /* { dg-error "invalid iterating variable in fast enumeration" } */
42
    ;
43
 
44
  for (object in [object enumerator]) /* Ok */
45
    ;
46
 
47
  for (object in [object classEnumerator]) /* Ok */
48
    ;
49
 
50
  for (12 in array) /* { dg-error "invalid iterating variable in fast enumeration" } */
51
    ;               /* { dg-error "iterating variable in fast enumeration is not an object" "" { target *-*-* } 50 } */
52
 
53
  for (object in 12) /* { dg-error "collection in fast enumeration is not an object" } */
54
    ;
55
 
56
  for (object in invalid) /* { dg-error "collection in fast enumeration is not an object" } */
57
    ;
58
 
59
  for (invalid in [object enumerator]) /* { dg-error "iterating variable in fast enumeration is not an object" } */
60
    ;
61
 
62
  return 0;
63
}

powered by: WebSVN 2.1.0

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