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