diff --git a/tools/widl/parser.y b/tools/widl/parser.y index bdbd44040ca..9db8ebd6fc4 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -1880,7 +1880,7 @@ type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, in nt->t = t; nt->next = namespace->type_hash[hash]; namespace->type_hash[hash] = nt; - if ((t == tsSTRUCT || t == tsUNION)) + if ((t == tsUNION)) fix_incomplete_types(type); return type; } diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index a066125b167..05e96844d8c 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -291,31 +291,27 @@ type_t *type_new_enum(const char *name, struct namespace *namespace, int defined type_t *type_new_struct(char *name, struct namespace *namespace, int defined, var_list_t *fields) { - type_t *tag_type = name ? find_type(name, namespace, tsSTRUCT) : NULL; - type_t *t; + type_t *t = NULL; - /* avoid creating duplicate typelib type entries */ - if (tag_type && do_typelib) return tag_type; + if (name) + t = find_type(name, namespace, tsSTRUCT); - t = make_type(TYPE_STRUCT); - t->name = name; - t->namespace = namespace; + if (!t) + { + t = make_type(TYPE_STRUCT); + t->name = name; + t->namespace = namespace; + if (name) + reg_type(t, name, namespace, tsSTRUCT); + } - if (tag_type && tag_type->details.structure) - t->details.structure = tag_type->details.structure; - else if (defined) + if (!t->defined && defined) { t->details.structure = xmalloc(sizeof(*t->details.structure)); t->details.structure->fields = fields; t->defined = TRUE; } - if (name) - { - if (defined) - reg_type(t, name, namespace, tsSTRUCT); - else - add_incomplete(t); - } + return t; }