cp-tree.h (lang_identifier): Remove class_value.
[gcc.git] / gcc / testsuite / objc.dg / encode-4.m
1 /* Encoding tests for ObjC class layouts. */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
3 /* { dg-options "-lobjc" } */
4 /* { dg-do run } */
5
6 #include <objc/Object.h>
7 #ifdef __NEXT_RUNTIME__
8 #include <objc/objc-class.h>
9 #define OBJC_GETCLASS objc_getClass
10 #else
11 #include <objc/objc-api.h>
12 #define OBJC_GETCLASS objc_get_class
13 #endif
14
15 extern void abort(void);
16 extern int strcmp(const char *s1, const char *s2);
17 #define CHECK_IF(expr) if(!(expr)) abort()
18
19 @class Int1, Int2;
20 struct Nested;
21
22 struct Innermost {
23 unsigned char a, b;
24 struct Nested *encl;
25 };
26
27 struct Nested {
28 float a, b;
29 Int1 *next;
30 struct Innermost innermost;
31 };
32
33 @interface Int1: Object {
34 signed char a, b;
35 Int2 *int2;
36 struct Nested nested;
37 }
38 @end
39
40 @interface Int2: Int1 {
41 struct Innermost *innermost;
42 Int1 *base;
43 }
44 @end
45
46 @implementation Int1
47 @end
48
49 @implementation Int2
50 @end
51
52 struct objc_ivar *ivar;
53
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));
57 ivar++;
58 }
59
60 int main(void) {
61 ivar = ((Class)OBJC_GETCLASS("Int1"))->ivars->ivar_list;
62 check_ivar("a", "c");
63 check_ivar("b", "c");
64 check_ivar("int2", "@\"Int2\"");
65 check_ivar("nested",
66 "{Nested=\"a\"f\"b\"f\"next\"@\"Int1\"\"innermost\"{Innermost=\"a\"C\"b\"C\"encl\"^{Nested}}}");
67
68 ivar = ((Class)OBJC_GETCLASS("Int2"))->ivars->ivar_list;
69 check_ivar("innermost", "^{Innermost=CC^{Nested}}");
70 check_ivar("base", "@\"Int1\"");
71
72 return 0;
73 }