* gcc.dg/stack-check-5.c: Skip with -fstack-protector.
[official-gcc.git] / gcc / testsuite / obj-c++.dg / isa-field-1.mm
blob4501d01a11e605d36771671817b0aa5aa7b035a6
1 /* Ensure there are no bizarre difficulties with accessing the 'isa' field of objects.  */
2 /* { dg-do compile } */
4 #include "../objc-obj-c++-shared/TestsuiteObject.h"
5 #include "../objc-obj-c++-shared/runtime.h"
7 @interface TestsuiteObject (Test)
8 - (Class) test1: (id)object;
9 @end
11 @interface Derived: TestsuiteObject
12 - (Class) test2: (id)object;
13 @end
15 @implementation TestsuiteObject (Test)
17 Class test1(id object) {
18 #ifdef __NEXT_RUNTIME__
19     Class cls = object->isa;
20 #else
21     Class cls = object->class_pointer;
22 #endif
23     return cls;
25 - (Class) test1: (id)object {
26 #ifdef __NEXT_RUNTIME__
27     Class cls = object->isa;
28 #else
29     Class cls = object->class_pointer;
30 #endif
31     return cls;
34 @end
36 @implementation Derived
38 Class test2(id object) {
39 #ifdef __NEXT_RUNTIME__
40     Class cls = object->isa;
41 #else
42     Class cls = object->class_pointer;
43 #endif
44     return cls;
46 - (Class) test2: (id)object {
47 #ifdef __NEXT_RUNTIME__
48     Class cls = object->isa;
49 #else
50     Class cls = object->class_pointer;
51 #endif
52     return cls;
55 @end
57 Class test3(id object) {
58 #ifdef __NEXT_RUNTIME__
59     Class cls = object->isa;
60 #else
61     Class cls = object->class_pointer;
62 #endif
63     return cls;