Debian Codegraph @

gcc/testsuite/objc.dg/fobjc-std-1.m

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;
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) 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 @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
31
32 __attribute__ ((deprecated))
33 @interface MyRootClass2 /* { dg-error "class attributes are not available in Objective.C 1.0" } */
34 {
35 Class isa;
36 }
37 @end
38
39 __attribute__ ((deprecated))
40 @protocol MyProtocol
41 - (id) test; /* { dg-error "protocol attributes are not available in Objective.C 1.0" } */
42 @required /* { dg-error "not available in Objective.C 1.0" } */
43 - (id) variable __attribute__ ((deprecated)); /* { dg-error "not available in Objective.C 1.0" } */
44 @optional /* { dg-error "not available in Objective.C 1.0" } */
45 @end
46
47 @interface MyRootClass (NSFastEnumeration)
48 - (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
49 objects:(id *)stackbuf
50 count:(unsigned int)len;
51 @end
52
53 @class NSArray;
54
55 int array_length (NSArray *array)
56 {
57 int i = 0;
58
59 for (id object in array) /* { dg-error "not available in Objective.C 1.0" } */
60 i++;
61
62 return i;
63 }
64
65 id test (void)
66 {
67 return MyRootClass.name; /* { dg-error "not available in Objective.C 1.0" } */
68 }
69
70 @interface MyRootClass3
71 {
72 Class isa;
73 }
74 @end
75
76 @interface MyRootClass3 ()
77 @end /* { dg-error "not available in Objective.C 1.0" } */