diff --git a/tools/qfcc/include/class.h b/tools/qfcc/include/class.h index 4b609c5d7..a2cf55182 100644 --- a/tools/qfcc/include/class.h +++ b/tools/qfcc/include/class.h @@ -153,6 +153,7 @@ void protocol_add_protocols (protocol_t *protocol, protocollist_t *protocols); struct def_s *protocol_def (protocol_t *protocol); protocollist_t *new_protocol_list (void); protocollist_t *add_protocol (protocollist_t *protocollist, const char *name); +int procollist_find_protocol (protocollist_t *protocollist, protocol_t *proto); int compare_protocols (protocollist_t *protos1, protocollist_t *protos2); void print_protocollist (struct dstring_s *dstr, protocollist_t *protocollist); struct def_s *emit_protocol (protocol_t *protocol); diff --git a/tools/qfcc/source/class.c b/tools/qfcc/source/class.c index 419984960..ecc69c074 100644 --- a/tools/qfcc/source/class.c +++ b/tools/qfcc/source/class.c @@ -1295,10 +1295,12 @@ add_protocol (protocollist_t *protocollist, const char *name) return protocollist; } -static int +int procollist_find_protocol (protocollist_t *protocollist, protocol_t *proto) { int i; + if (!protocollist) + return 0; for (i = 0; i < protocollist->count; i++) if (protocollist->list[i] == proto) return 1; @@ -1310,7 +1312,7 @@ compare_protocols (protocollist_t *protos1, protocollist_t *protos2) { int i; - if (protos2 == protos2) + if (protos1 == protos2) return 1; if (!protos1 || !protos2) return 0; diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index f04e27048..108da09f0 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -466,8 +466,9 @@ type_specifier { if ($2) { type_t type = *type_id.t.fldptr.type; + type.next = 0; type.protos = $2; - $$ = make_spec (pointer_type (&type), 0, 0, 0); + $$ = make_spec (pointer_type (find_type (&type)), 0, 0, 0); } else { $$ = make_spec (&type_id, 0, 0, 0); } @@ -476,6 +477,7 @@ type_specifier { if ($2) { type_t type = *$1->type; + type.next = 0; type.protos = $2; $$ = make_spec (find_type (&type), 0, 0, 0); } else { diff --git a/tools/qfcc/source/type.c b/tools/qfcc/source/type.c index 262f26964..c8d56b659 100644 --- a/tools/qfcc/source/type.c +++ b/tools/qfcc/source/type.c @@ -237,7 +237,6 @@ types_same (type_t *a, type_t *b) case ev_pointer: if (a->t.fldptr.type != b->t.fldptr.type) return 0; - return compare_protocols (a->protos, b->protos); case ev_func: if (a->t.func.type != b->t.func.type || a->t.func.num_params != b->t.func.num_params) @@ -259,6 +258,8 @@ types_same (type_t *a, type_t *b) case ty_enum: if (strcmp (a->name, b->name)) return 0; + if (a->meta == ty_struct) + return compare_protocols (a->protos, b->protos); return 1; case ty_array: if (a->t.array.type != b->t.array.type @@ -269,7 +270,7 @@ types_same (type_t *a, type_t *b) case ty_class: if (a->t.class != b->t.class) return 0; - return 1; + return compare_protocols (a->protos, b->protos); } internal_error (0, "we be broke"); }