From: Richard Pospesel Subject: [PATCH 08/15] widl: type_new_alias function now takes decl_spec_t for aliasee rather than type_t Message-Id: <20190705215144.7474-7-richard@torproject.org> Date: Fri, 5 Jul 2019 14:51:37 -0700 In-Reply-To: <20190705215144.7474-6-richard@torproject.org> References: <20190705215003.7384-1-richard@torproject.org> <20190705215144.7474-1-richard@torproject.org> <20190705215144.7474-2-richard@torproject.org> <20190705215144.7474-3-richard@torproject.org> <20190705215144.7474-4-richard@torproject.org> <20190705215144.7474-5-richard@torproject.org> <20190705215144.7474-6-richard@torproject.org> Signed-off-by: Richard Pospesel --- tools/widl/parser.y | 12 +++++++++--- tools/widl/typetree.c | 9 +++------ tools/widl/typetree.h | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/widl/parser.y b/tools/widl/parser.y index f3414e1f70..07261b99dc 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -1190,7 +1190,8 @@ static void decl_builtin_basic(const char *name, enum type_basic_type type) static void decl_builtin_alias(const char *name, type_t *t) { - reg_type(type_new_alias(t, name), name, NULL, 0); + decl_spec_t ds; + reg_type(type_new_alias(init_declspec(&ds, t), name), name, &global_namespace, 0); } void init_types(void) @@ -1808,8 +1809,13 @@ static declarator_t *make_declarator(var_t *var) static type_t *make_safearray(type_t *type) { + decl_spec_t aliasee_ds; decl_spec_t element_ds; - init_declspec(&element_ds, type_new_alias(type, "SAFEARRAY")); + + init_declspec(&element_ds, + type_new_alias( + init_declspec(&aliasee_ds, type), + "SAFEARRAY")); return type_new_array(NULL, &element_ds, TRUE, 0, NULL, NULL, FC_RP); @@ -2006,7 +2012,7 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at cur->loc_info.line_number); name = declare_var(attrs, decl_spec, decl, 0); - cur = type_new_alias(name->declspec.type, name->name); + cur = type_new_alias(&name->declspec, name->name); cur->attrs = attrs; if (is_incomplete(cur)) diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index 6b50271377..282f0dbbab 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -186,16 +186,13 @@ type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t return t; } -type_t *type_new_alias(type_t *t, const char *name) +type_t *type_new_alias(const decl_spec_t *ds, const char *name) { - type_t *a = make_type(t->type_type); - + type_t *a = make_type(ds->type->type_type); a->name = xstrdup(name); a->attrs = NULL; - a->details.alias.aliasee.type = t; + a->details.alias.aliasee = *ds; a->is_alias = TRUE; - init_loc_info(&a->loc_info); - return a; } diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index 59bfb29fa4..9434075108 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -31,7 +31,7 @@ enum name_type { type_t *type_new_function(var_list_t *args); type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs); -type_t *type_new_alias(type_t *t, const char *name); +type_t *type_new_alias(const decl_spec_t *aliasee, const char *name); type_t *type_new_module(char *name); type_t *type_new_array(const char* name, const decl_spec_t *element, int declptr, unsigned int dim, expr_t *size_is, expr_t *length_is, -- 2.17.1