Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / obj-c++.dg / fobjc-std-1.mm
blob59db95091db550f1897f7a4bc5d96313bed249ce
1 /* Test warnings when using -fobjc-std=objc1.  */
2 /* { dg-do compile } */
3 /* { dg-options "-fobjc-std=objc1" } */
5 #include <objc/objc.h>
7 @interface MyRootClass
9   Class isa; /* { dg-error ".@package. is not available in Objective.C 1.0" } */
10 @package
11   int a;
12   int b;
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
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
35 __attribute__ ((deprecated))
36 @interface MyRootClass2 /* { dg-error "class attributes are not available in Objective.C 1.0" } */
38   Class isa;
40 @end
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
56 @class NSArray;
58 int array_length (NSArray *array)
60   int i = 0;
62   for (id object in array) /*  dg-error "not available in Objective.C 1.0"  */
63     i++;
64       
65   return i;
67 #endif
69 id test (void)
71   return MyRootClass.name; /* { dg-error "not available in Objective.C 1.0" } */
74 @interface MyRootClass3
76   Class isa;
78 @end
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 */