Debian Codegraph @

gcc/testsuite/obj-c++.dg/fobjc-std-1.mm

raw
1 /* Test warnings when using -fobjc-std=objc1. */
2 /* { dg-do compile } */
3 /* { dg-options "-fobjc-std=objc1" } */
4 // { dg-additional-options "-Wno-objc-root-class" }
5
6 #include <objc/objc.h>
7
8 @interface MyRootClass
9 {
10 Class isa; /* { dg-error ".@package. is not available in Objective.C 1.0" } */
11 @package
12 int a;
13 int b;
14 }
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
22
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 /* There is a problem with the testsuite on the following line; the compiler seems Ok, but the testsuite still barfs. */
29 /*@synthesize a;*/ /* dg-error "not available in Objective.C 1.0" */
30 /* The following lines replace the synthesize to prevent warnings. */
31 - (int) a { return a; }
32 - (void) setA: (int)value { a = value; }
33 @dynamic b; /* { dg-error "not available in Objective.C 1.0" } */
34 @end
35
36 __attribute__ ((deprecated))
37 @interface MyRootClass2 /* { dg-error "class attributes are not available in Objective.C 1.0" } */
38 {
39 Class isa;
40 }
41 @end
42
43 __attribute__ ((deprecated))
44 @protocol MyProtocol /* { dg-error "protocol attributes are not available in Objective.C 1.0" } */
45 - (id) test;
46 @required /* { dg-error "not available in Objective.C 1.0" } */
47 - (id) variable __attribute__ ((deprecated)); /* { dg-error "not available in Objective.C 1.0" } */
48 @optional /* { dg-error "not available in Objective.C 1.0" } */
49 @end
50 #if 0 /* fast enumeration is not implemented even in Objective-C 2.0 */
51 @interface MyRootClass (NSFastEnumeration)
52 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
53 objects:(id *)stackbuf
54 count:(unsigned int)len;
55 @end
56
57 @class NSArray;
58
59 int array_length (NSArray *array)
60 {
61 int i = 0;
62
63 for (id object in array) /* dg-error "not available in Objective.C 1.0" */
64 i++;
65
66 return i;
67 }
68 #endif
69
70 id test (void)
71 {
72 return MyRootClass.name; /* { dg-error "not available in Objective.C 1.0" } */
73 }
74
75 @interface MyRootClass3
76 {
77 Class isa;
78 }
79 @end
80
81 /* There is a problem with the testsuite on the following line; the compiler seems Ok, but the testsuite still barfs. */
82 /* @interface MyRootClass3 () */ /* dg-error "not available in Objective.C 1.0" */
83 /* @end */