4 static int check_class(type *tp) {
8 //printf("\n"); DDMT(tp);
10 for (i = 0; i < get_class_n_members(tp); i++) {
12 entity *mem = get_class_member(tp, i);
13 assert(mem && "NULL members not allowed");
14 //printf(" %d, %d", get_entity_n_overwrites(mem), get_class_n_supertypes(tp)); DDME(mem);
15 if (!mem) return error_null_mem;
16 assert(get_entity_n_overwrites(mem) <= get_class_n_supertypes(tp));
17 for (j = 0; j < get_entity_n_overwrites(mem); j++) {
18 entity *ovw = get_entity_overwrites(mem, j);
19 //printf(" overwrites: "); DDME(ovw);
20 /* Check whether ovw is member of one of tp's supertypes. If so,
21 the representation is correct. */
23 for (k = 0; k < get_class_n_supertypes(tp); k++) {
24 if (get_class_member_index(get_class_supertype(tp, k), ovw) >= 0) {
31 assert(found && "overwrites an entity not contained in direct supertype");
32 return error_ent_not_cont;
40 static int check_type(type *tp) {
41 switch (get_type_tpop_code(tp)) {
43 return check_class(tp);
54 static void on_obstack(ir_node *n; void *env) {
55 struct obstack *obst = ((myenv *)env)->obst;
57 /* n must be on the obstack obst. */
59 ((myenv *)env)->res = 0;
62 static int constant_on_wrong_obstack(ir_node *n) {
64 env.res = 0; /* false, not on wrong obstack */
65 env.obst = get_irg_obst(get_const_code_irg());
66 irg_walk(n, on_obstack, NULL, (void *)&env);
70 static int constants_on_wrong_obstack(entity *ent) {
71 if (get_entity_variability(ent) == uninitialize) return 0;
73 if (is_compound_entity(ent)) {
75 for (i = 0; i < get_compound_ent_n_values(ent); i++) {
76 if (constant_on_wrong_obstack(get_compound_entity_value(ent, i)));
80 return constant_on_wrong_obstack(get_atomic_entity_value(ent));
85 static int check_entity(entity *ent) {
86 if (constants_on_wrong_obstack(ent))
87 return error_const_on_wrong_obstack;
91 static void check_tore(type_or_ent *tore, void *env) {
94 *res = check_type((type *)tore);
96 assert(is_entity(tore));
97 *res = check_entity((entity *)tore);
105 type_walk(check_tore, NULL, &res);