From ed50ce5efe04b65c0fe5648d2c8622b493b074fd Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 26 Feb 2013 14:52:54 +0100 Subject: [PATCH] widl: Allow shadowing imported types with typedef. --- tools/widl/parser.y | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/widl/parser.y b/tools/widl/parser.y index d8435b94e81..b7fa2f6d97e 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -1868,7 +1868,17 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at var_t *name; cur = find_type(decl->var->name, 0); - if (cur) + + /* + * MIDL allows shadowing types that are declared in imported files. + * We don't throw an error in this case and instead add a new type + * (which is earlier on the list in hash table, so it will be used + * instead of shadowed type). + * + * FIXME: We may consider string separated type tables for each input + * for cleaner solution. + */ + if (cur && input_name == cur->loc_info.input_name) error_loc("%s: redefinition error; original definition was at %s:%d\n", cur->name, cur->loc_info.input_name, cur->loc_info.line_number);