5 #include <objc/runtime.h>
8 @interface Sub1 : TestRoot {
14 @implementation Sub1 @end
16 @interface Sub2 : Sub1 {
17 // id isa // 0..4 0..8
18 // BOOL b // 4..5 8..9
19 BOOL b2; // 5..6 9..10
23 @implementation Sub2 @end
25 @interface Sub3 : Sub1 {
26 // id isa; // 0..4 0..8
27 // BOOL b; // 4..5 8..9
29 BOOL b2; // 12..13 24..25
32 @implementation Sub3 @end
36 testassert(sizeof(id) == class_getInstanceSize([TestRoot class]));
37 testassert(2*sizeof(id) == class_getInstanceSize([Sub1 class]));
38 testassert(3*sizeof(id) == class_getInstanceSize([Sub2 class]));
39 testassert(4*sizeof(id) == class_getInstanceSize([Sub3 class]));
41 #if !__has_feature(objc_arc)
45 testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(object_getClass(o)));
48 testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(object_getClass(o)));
51 testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(object_getClass(o)));
54 testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(object_getClass(o)));