Auto-cast between enums and the default type.

This commit is contained in:
Bill Currie 2011-02-06 20:08:16 +09:00
parent 6b7a81f5a7
commit e4ac92b5f2
2 changed files with 7 additions and 1 deletions

View file

@ -2358,6 +2358,9 @@ cast_expr (type_t *type, expr_t *e)
if (type == e_type)
return e;
if ((type == type_default && is_enum (e_type))
|| (is_enum (type) && e_type == type_default))
return e;
if (!(type->type == ev_pointer
&& (e_type->type == ev_pointer
|| e_type == &type_integer //|| e_type == &type_uinteger

View file

@ -498,7 +498,10 @@ static sblock_t *
expr_symbol (sblock_t *sblock, expr_t *e, operand_t **op)
{
*op = new_operand (op_symbol);
(*op)->type = e->e.symbol->type->type;
if (is_enum (e->e.symbol->type))
(*op)->type = type_default->type;
else
(*op)->type = e->e.symbol->type->type;
(*op)->o.symbol = e->e.symbol;
return sblock;
}