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" } { "" } } */
7 #include "../objc-obj-c++-shared/TestsuiteObject.m"
8 #include "../objc-obj-c++-shared/runtime.h"
10 extern void abort(void);
11 extern int strcmp(const char *s1, const char *s2);
13 #define CHECK_IF(expr) if(!(expr)) abort()
26 struct Innermost innermost;
29 @interface Int1: TestsuiteObject {
36 @interface Int2: Int1 {
37 struct Innermost *innermost;
48 #if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
49 struct objc_ivar *ivar;
54 static void check_ivar(const char *name, const char *type) {
55 #if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
56 CHECK_IF(!strcmp(ivar->ivar_name, name));
57 CHECK_IF(!strcmp(ivar->ivar_type, type));
59 CHECK_IF(!strcmp(ivar_getName(*ivar), name));
60 CHECK_IF(!strcmp(ivar_getTypeEncoding(*ivar), type));
66 #if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
67 ivar = ((Class)objc_getClass("Int1"))->ivars->ivar_list;
69 ivar = class_copyIvarList ((Class)objc_getClass("Int1"), NULL);
73 check_ivar("int2", "@\"Int2\"");
75 "{Nested=\"a\"f\"b\"f\"next\"@\"Int1\"\"innermost\"{Innermost=\"a\"C\"b\"C\"encl\"^{Nested}}}");
77 #if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
78 ivar = ((Class)objc_getClass("Int2"))->ivars->ivar_list;
80 ivar = class_copyIvarList ((Class)objc_getClass("Int2"), NULL);
82 check_ivar("innermost", "^{Innermost=CC^{Nested}}");
83 check_ivar("base", "@\"Int1\"");