1 /* Encoding tests for ObjC class layouts. */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
3 /* { dg-options "-lobjc" } */
6 #include <objc/Object.h>
7 #ifdef __NEXT_RUNTIME__
8 #include <objc/objc-class.h>
9 #define OBJC_GETCLASS objc_getClass
11 #include <objc/objc-api.h>
12 #define OBJC_GETCLASS objc_get_class
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 struct objc_ivar *ivar;
55 static void check_ivar(const char *name, const char *type) {
56 CHECK_IF(!strcmp(ivar->ivar_name, name));
57 CHECK_IF(!strcmp(ivar->ivar_type, type));
62 ivar = ((Class)OBJC_GETCLASS("Int1"))->ivars->ivar_list;
65 check_ivar("int2", "@\"Int2\"");
67 "{Nested=\"a\"f\"b\"f\"next\"@\"Int1\"\"innermost\"{Innermost=\"a\"C\"b\"C\"encl\"^{Nested}}}");
69 ivar = ((Class)OBJC_GETCLASS("Int2"))->ivars->ivar_list;
70 check_ivar("innermost", "^{Innermost=CC^{Nested}}");
71 check_ivar("base", "@\"Int1\"");