PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / objc.dg / foreach-7.m
blob7ceff075016a1bfe94d3bff5afa3150b108b0203
1 /* Test basic Objective-C foreach syntax.  This tests warnings and errors.  */
2 /* 
3    { dg-options "-ftrack-macro-expansion=0" }
4    { dg-do compile } 
5 */
7 #import "../objc-obj-c++-shared/TestsuiteObject.h"
8 #import <objc/objc.h>
9 #undef  nil
10 #define nil ((id)0)
12 struct __objcFastEnumerationState
14   unsigned long state;
15   id            *itemsPtr;
16   unsigned long *mutationsPtr;
17   unsigned long extra[5];
20 @interface TestsuiteObject (NSFastEnumeration)
21 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
22                                      objects:(id *)stackbuf 
23                                        count:(unsigned int)len;
24 - (id) enumerator;
25 @end
27 void function (void)
29   return;
32 id object_function (void)
34   return nil;
37 int main (void)
39   id array = nil;
40   id object = nil;
42   for (typedef int my_typedef in array) /* { dg-error "declaration of non-variable" } */
43     ;                                   /* { dg-error "iterating variable in fast enumeration is not an object" "" { target *-*-* } .-1 } */
45   for (function () in nil) /* { dg-error "invalid iterating variable in fast enumeration" } */
46     ;                      /* { dg-error "iterating variable in fast enumeration is not an object" "" { target *-*-* } .-1 } */
48   for (object_function () in nil) /* { dg-error "invalid iterating variable in fast enumeration" } */
49     ;
51   for ([object enumerator] in array) /* { dg-error "invalid iterating variable in fast enumeration" } */
52     ;
54   for (object = nil in array) /* { dg-error "invalid iterating variable in fast enumeration" } */
55     ;
57   for (id key, value in array) /* { dg-error "multiple iterating variables in fast enumeration" } */
58     ;
60   return 0;