In gcc/: 2010-11-03 Nicola Pero <nicola.pero@meta-innovation.com>
[gcc.git] / gcc / testsuite / objc.dg / fobjc-std-1.m
1 /* Test warnings when using -fobjc-std=objc1. */
2 /* { dg-do compile } */
3 /* { dg-options "-fobjc-std=objc1" } */
4
5 #include <objc/objc.h>
6
7 __attribute__ ((deprecated))
8 @interface MyRootClass
9 { /* { dg-error "class attributes are not available in Objective.C 1.0" } */
10 Class isa;
11 @package /* { dg-error "not available in Objective.C 1.0" } */
12 int a;
13 int b;
14 }
15 + (id) alloc __attribute__ ((deprecated)); /* { dg-error "not available in Objective.C 1.0" } */
16 - (id) init;
17 - (id) testMe: (id) __attribute__((unused)) argument; /* { dg-error "not available in Objective.C 1.0" } */
18 @property (nonatomic) int a; /* { dg-error "not available in Objective.C 1.0" } */
19 @property (nonatomic) int b; /* { dg-error "not available in Objective.C 1.0" } */
20 @end
21
22 @implementation MyRootClass
23 + (id) alloc { return self; }
24 - (id) init { return self; }
25 - (id) testMe: (id) __attribute__((unused)) argument { return self; } /* { dg-error "not available in Objective.C 1.0" } */
26 @synthesize a; /* { dg-error "not available in Objective.C 1.0" } */
27 @dynamic b; /* { dg-error "not available in Objective.C 1.0" } */
28 @end
29
30 __attribute__ ((deprecated))
31 @protocol MyProtocol
32 - (id) test; /* { dg-error "protocol attributes are not available in Objective.C 1.0" } */
33 @required /* { dg-error "not available in Objective.C 1.0" } */
34 - (id) variable __attribute__ ((deprecated)); /* { dg-error "not available in Objective.C 1.0" } */
35 @optional /* { dg-error "not available in Objective.C 1.0" } */
36 @end
37
38 @interface MyRootClass (NSFastEnumeration)
39 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
40 objects:(id *)stackbuf
41 count:(unsigned int)len;
42 @end
43
44 @class NSArray;
45
46 int array_length (NSArray *array)
47 {
48 int i = 0;
49
50 for (id object in array) /* { dg-error "not available in Objective.C 1.0" } */
51 i++;
52
53 return i;
54 }