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/Object1.h"
8 #include "../objc-obj-c++-shared/next-mapping.h"
9 #ifdef __NEXT_RUNTIME__
10 #include <objc/objc-class.h>
12 #include <objc/objc-api.h>
15 extern void abort(void);
16 extern int strcmp(const char *s1, const char *s2);
18 #define CHECK_IF(expr) if(!(expr)) abort()
31 struct Innermost innermost;
34 @interface Int1: Object {
41 @interface Int2: Int1 {
42 struct Innermost *innermost;
53 #ifdef NEXT_OBJC_USE_NEW_INTERFACE
56 struct objc_ivar *ivar;
59 static void check_ivar(const char *name, const char *type) {
60 #ifdef NEXT_OBJC_USE_NEW_INTERFACE
61 CHECK_IF(!strcmp(ivar_getName(*ivar), name));
62 CHECK_IF(!strcmp(ivar_getTypeEncoding(*ivar), type));
64 CHECK_IF(!strcmp(ivar->ivar_name, name));
65 CHECK_IF(!strcmp(ivar->ivar_type, type));
71 #ifdef NEXT_OBJC_USE_NEW_INTERFACE
72 ivar = class_copyIvarList ((Class)objc_get_class("Int1"), NULL);
74 ivar = ((Class)objc_get_class("Int1"))->ivars->ivar_list;
78 check_ivar("int2", "@\"Int2\"");
80 "{Nested=\"a\"f\"b\"f\"next\"@\"Int1\"\"innermost\"{Innermost=\"a\"C\"b\"C\"encl\"^{Nested}}}");
82 #ifdef NEXT_OBJC_USE_NEW_INTERFACE
83 ivar = class_copyIvarList ((Class)objc_get_class("Int2"), NULL);
85 ivar = ((Class)objc_get_class("Int2"))->ivars->ivar_list;
87 check_ivar("innermost", "^{Innermost=CC^{Nested}}");
88 check_ivar("base", "@\"Int1\"");
93 #include "../objc-obj-c++-shared/Object1-implementation.h"