widl: Make the rules for parsing fields in structures, encapsulated unions and non-encapsulated unions more strict.

Move the rules in fields that handle empty union cases into separate 
union rules so that they can't erroneously be accepted for structures or 
other types of unions.
oldstable
Rob Shearman 2008-04-25 10:58:40 +01:00 committed by Alexandre Julliard
parent 21cd6865c8
commit 14dd441c5b
1 changed files with 18 additions and 7 deletions

View File

@ -287,8 +287,8 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s
%type <type> type
%type <ifref> coclass_int
%type <ifref_list> coclass_ints
%type <var> arg field s_field case enum constdef externdef
%type <var_list> m_args no_args args fields cases enums enum_list dispint_props
%type <var> arg field ne_union_field union_field s_field case enum constdef externdef
%type <var_list> m_args no_args args fields ne_union_fields cases enums enum_list dispint_props
%type <var> m_ident t_ident ident
%type <declarator> declarator func_declarator direct_declarator
%type <declarator_list> declarator_list
@ -576,11 +576,11 @@ cases: { $$ = NULL; }
| cases case { $$ = append_var( $1, $2 ); }
;
case: tCASE expr_const ':' field { attr_t *a = make_attrp(ATTR_CASE, append_expr( NULL, $2 ));
case: tCASE expr_const ':' union_field { attr_t *a = make_attrp(ATTR_CASE, append_expr( NULL, $2 ));
$$ = $4; if (!$$) $$ = make_var(NULL);
$$->attrs = append_attr( $$->attrs, a );
}
| tDEFAULT ':' field { attr_t *a = make_attr(ATTR_DEFAULT);
| tDEFAULT ':' union_field { attr_t *a = make_attr(ATTR_DEFAULT);
$$ = $3; if (!$$) $$ = make_var(NULL);
$$->attrs = append_attr( $$->attrs, a );
}
@ -707,10 +707,20 @@ fields: { $$ = NULL; }
field: s_field ';' { $$ = $1; }
| m_attributes uniondef ';' { $$ = make_var(NULL); $$->type = $2; $$->attrs = $1; }
| attributes ';' { $$ = make_var(NULL); $$->attrs = $1; }
| ';' { $$ = NULL; }
;
ne_union_field:
s_field ';' { $$ = $1; }
| attributes ';' { $$ = make_var(NULL); $$->attrs = $1; }
ne_union_fields: { $$ = NULL; }
| ne_union_fields ne_union_field { $$ = append_var( $1, $2 ); }
;
union_field:
s_field ';' { $$ = $1; }
| ';' { $$ = NULL; }
s_field: m_attributes type declarator { $$ = $3->var;
$$->attrs = check_field_attrs($$->name, $1);
set_type($$, $2, $3, FALSE);
@ -990,7 +1000,8 @@ typedef: tTYPEDEF m_attributes type declarator_list
}
;
uniondef: tUNION t_ident '{' fields '}' { $$ = get_typev(RPC_FC_NON_ENCAPSULATED_UNION, $2, tsUNION);
uniondef: tUNION t_ident '{' ne_union_fields '}'
{ $$ = get_typev(RPC_FC_NON_ENCAPSULATED_UNION, $2, tsUNION);
$$->kind = TKIND_UNION;
$$->fields_or_args = $4;
$$->defined = TRUE;