Signed-off-by: Zebediah Figura z.figura12@gmail.com --- tools/widl/typetree.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index faa582034f..524d00571f 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -285,6 +285,8 @@ type_t *type_new_enum(const char *name, struct namespace *namespace, int defined t->details.enumeration->enums = enums; t->defined = TRUE; } + else if (defined) + error_loc("redefinition of enum %s\n", name);
return t; } @@ -311,6 +313,8 @@ type_t *type_new_struct(char *name, struct namespace *namespace, int defined, va t->details.structure->fields = fields; t->defined = TRUE; } + else if (defined) + error_loc("redefinition of struct %s\n", name);
return t; } @@ -336,6 +340,8 @@ type_t *type_new_nonencapsulated_union(const char *name, int defined, var_list_t t->details.structure->fields = fields; t->defined = TRUE; } + else if (defined) + error_loc("redefinition of union %s\n", name);
return t; } @@ -367,6 +373,8 @@ type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *unio t->details.structure->fields = append_var(t->details.structure->fields, union_field); t->defined = TRUE; } + else + error_loc("redefinition of union %s\n", name);
return t; }
From: Richard Pospesel richard@torproject.org
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- tools/widl/parser.y | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y index a52afc7921..072e138ecf 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -2573,10 +2573,15 @@ static void check_field_common(const type_t *container_type, type = type_array_get_element_type(type); more_to_do = TRUE; break; + case TGT_ENUM: + type = type_get_real_type(type); + if (!type_is_complete(type)) + { + error_loc_info(&arg->loc_info, "undefined type declaration "enum %s"\n", type->name); + } case TGT_USER_TYPE: case TGT_IFACE_POINTER: case TGT_BASIC: - case TGT_ENUM: case TGT_RANGE: /* nothing to do */ break; @@ -2601,10 +2606,15 @@ static void check_remoting_fields(const var_t *var, type_t *type) if (type_is_complete(type)) fields = type_struct_get_fields(type); else - error_loc_info(&var->loc_info, "undefined type declaration %s\n", type->name); + error_loc_info(&var->loc_info, "undefined type declaration "struct %s"\n", type->name); } else if (type_get_type(type) == TYPE_UNION || type_get_type(type) == TYPE_ENCAPSULATED_UNION) - fields = type_union_get_cases(type); + { + if (type_is_complete(type)) + fields = type_union_get_cases(type); + else + error_loc_info(&var->loc_info, "undefined type declaration "union %s"\n", type->name); + }
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry ) if (field->declspec.type) check_field_common(type, type->name, field);