1 /* Encoding tests for ObjC class layouts. */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
3 /* { dg-options "" } */
5 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
6 #include "../objc-obj-c++-shared/TestsuiteObject.m"
7 #include "../objc-obj-c++-shared/runtime.h"
12 #define CHECK_IF(expr) if(!(expr)) abort()
25 struct Innermost innermost;
28 @interface Int1: TestsuiteObject {
35 @interface Int2: Int1 {
36 struct Innermost *innermost;
47 #if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
48 struct objc_ivar *ivar;
53 static void check_ivar(const char *name, const char *type) {
54 #if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
55 CHECK_IF(!strcmp(ivar->ivar_name, name));
56 CHECK_IF(!strcmp(ivar->ivar_type, type));
58 CHECK_IF(!strcmp(ivar_getName(*ivar), name));
59 CHECK_IF(!strcmp(ivar_getTypeEncoding(*ivar), type));
65 #if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
66 ivar = ((Class)objc_getClass("Int1"))->ivars->ivar_list;
68 ivar = class_copyIvarList ((Class)objc_getClass("Int1"), NULL);
72 check_ivar("int2", "@\"Int2\"");
74 "{Nested=\"a\"f\"b\"f\"next\"@\"Int1\"\"innermost\"{Innermost=\"a\"C\"b\"C\"encl\"^{Nested}}}");
76 #if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
77 ivar = ((Class)objc_getClass("Int2"))->ivars->ivar_list;
79 ivar = class_copyIvarList ((Class)objc_getClass("Int2"), NULL);
81 check_ivar("innermost", "^{Innermost=CC^{Nested}}");
82 check_ivar("base", "@\"Int1\"");