PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / objc.dg / foreach-8.m
blob9a68e9ffb0565459e3df766914fc2858478aeb58
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
2 /* { dg-options "-Wall" } */
3 /* { dg-do compile } */
5 /* Test that fast enumeration loops where the iterating variable is declared
6    but not used do not generate warnings.  */
8 /*
9 struct __objcFastEnumerationState
11   unsigned long state;
12   id            *itemsPtr;
13   unsigned long *mutationsPtr;
14   unsigned long extra[5];
17 @interface Object
19   Class isa;
21 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
22                                      objects:(id *)stackbuf 
23                                        count:(unsigned int)len;
24 - (id) enumerator;
25 - (Class) classEnumerator;
26 @end
28 unsigned int count_objects_in_collection (id collection)
30   unsigned int count = 0;
32   /* The following line should generate no warnings even with
33      -Wall.  */
34   for (id object in collection)
35     count++;
37   return count;
40 unsigned int count_objects_in_collection_2 (id collection)
42   unsigned int count = 0;
43   id object;
45   /* The following line should generate no warnings even with
46      -Wall.  */
47   for (object in collection)
48     count++;
50   return count;