Debian Codegraph @

gcc/testsuite/objc.dg/isa-field-1.m

raw
1 /* Ensure there are no bizarre difficulties with accessing the 'isa' field of objects. */
2 /* { dg-do compile } */
3 /* The use of isa is deprecated, but we still want to test that it works. */
4 /* { dg-additional-options "-Wno-deprecated-declarations" } */
5
6 #include "../objc-obj-c++-shared/TestsuiteObject.h"
7 #include "../objc-obj-c++-shared/runtime.h"
8
9 @interface TestsuiteObject (Test)
10 - (Class) test1: (id)object;
11 @end
12
13 @interface Derived: TestsuiteObject
14 - (Class) test2: (id)object;
15 @end
16
17 @implementation TestsuiteObject (Test)
18
19 Class test1(id object) {
20 #ifdef __NEXT_RUNTIME__
21 Class cls = object->isa;
22 #else
23 Class cls = object->class_pointer;
24 #endif
25 return cls;
26 }
27 - (Class) test1: (id)object {
28 #ifdef __NEXT_RUNTIME__
29 Class cls = object->isa;
30 #else
31 Class cls = object->class_pointer;
32 #endif
33 return cls;
34 }
35
36 @end
37
38 @implementation Derived
39
40 Class test2(id object) {
41 #ifdef __NEXT_RUNTIME__
42 Class cls = object->isa;
43 #else
44 Class cls = object->class_pointer;
45 #endif
46 return cls;
47 }
48 - (Class) test2: (id)object {
49 #ifdef __NEXT_RUNTIME__
50 Class cls = object->isa;
51 #else
52 Class cls = object->class_pointer;
53 #endif
54 return cls;
55 }
56
57 @end
58
59 Class test3(id object) {
60 #ifdef __NEXT_RUNTIME__
61 Class cls = object->isa;
62 #else
63 Class cls = object->class_pointer;
64 #endif
65 return cls;
66 }