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
15 extern void abort(void);
16 extern int strcmp(const char *s1, const char *s2);
17 #define CHECK_IF(expr) if(!(expr)) abort()
30 struct Innermost innermost;
33 @interface Int1: Object {
40 @interface Int2: Int1 {
41 struct Innermost *innermost;
52 struct objc_ivar *ivar;
54 static void check_ivar(const char *name, const char *type) {
55 CHECK_IF(!strcmp(ivar->ivar_name, name));
56 CHECK_IF(!strcmp(ivar->ivar_type, type));
61 ivar = ((Class)OBJC_GETCLASS("Int1"))->ivars->ivar_list;
64 check_ivar("int2", "@\"Int2\"");
66 "{Nested=\"a\"f\"b\"f\"next\"@\"Int1\"\"innermost\"{Innermost=\"a\"C\"b\"C\"encl\"^{Nested}}}");
68 ivar = ((Class)OBJC_GETCLASS("Int2"))->ivars->ivar_list;
69 check_ivar("innermost", "^{Innermost=CC^{Nested}}");
70 check_ivar("base", "@\"Int1\"");