OSDN Git Service

2010-12-10 Nicola Pero <nicola.pero@meta-innovation.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / obj-c++.dg / fobjc-std-1.mm
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 @interface MyRootClass
8 {
9   Class isa; /* { dg-error ".@package. is not available in Objective.C 1.0" } */
10 @package
11   int a;
12   int b;
13 }
14 + (id) alloc __attribute__ ((deprecated)); /* { dg-error "not available in Objective.C 1.0" } */
15 + (id) name;
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) name { return self; }
25 - (id) init  { return self; }
26 - (id) testMe: (id) __attribute__((unused)) argument { return self; } /* { dg-error "not available in Objective.C 1.0" } */
27 /* There is a problem with the testsuite on the following line; the compiler seems Ok, but the testsuite still barfs.  */
28 /*@synthesize a;*/ /* dg-error "not available in Objective.C 1.0" */
29 /* The following lines replace the synthesize to prevent warnings.  */
30 - (int) a { return a; }
31 - (void) setA: (int)value { a = value; }
32 @dynamic b; /* { dg-error "not available in Objective.C 1.0" } */
33 @end
34
35 __attribute__ ((deprecated))
36 @interface MyRootClass2 /* { dg-error "class attributes are not available in Objective.C 1.0" } */
37 {
38   Class isa;
39 }
40 @end
41
42 __attribute__ ((deprecated))
43 @protocol MyProtocol /* { dg-error "protocol attributes are not available in Objective.C 1.0" } */
44 - (id) test;
45 @required /* { dg-error "not available in Objective.C 1.0" } */
46 - (id) variable __attribute__ ((deprecated)); /* { dg-error "not available in Objective.C 1.0" } */
47 @optional /* { dg-error "not available in Objective.C 1.0" } */
48 @end
49 #if 0 /* fast enumeration is not implemented even in Objective-C 2.0 */
50 @interface MyRootClass (NSFastEnumeration)
51 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
52                                      objects:(id *)stackbuf 
53                                        count:(unsigned int)len;
54 @end
55
56 @class NSArray;
57
58 int array_length (NSArray *array)
59 {
60   int i = 0;
61
62   for (id object in array) /*  dg-error "not available in Objective.C 1.0"  */
63     i++;
64       
65   return i;
66 }
67 #endif
68
69 id test (void)
70 {
71   return MyRootClass.name; /* { dg-error "not available in Objective.C 1.0" } */
72 }
73
74 @interface MyRootClass3
75 {
76   Class isa;
77 }
78 @end
79
80 /* There is a problem with the testsuite on the following line; the compiler seems Ok, but the testsuite still barfs.  */
81 /* @interface MyRootClass3 () */ /* dg-error "not available in Objective.C 1.0" */
82 /* @end */