allow casting between function types

This commit is contained in:
Bill Currie 2003-03-10 21:23:05 +00:00
parent cbd2c42178
commit 627c6f70f5
3 changed files with 8 additions and 5 deletions

View file

@ -522,8 +522,10 @@ emit_sub_expr (expr_t *e, def_t *dest)
return emit_deref_expr (e, dest);
case 'C':
def_a = emit_sub_expr (e->e.expr.e1, 0);
if (def_a->type->type == ev_pointer
&& e->e.expr.type->type == ev_pointer) {
if ((def_a->type->type == ev_pointer
&& e->e.expr.type->type == ev_pointer)
|| (def_a->type->type == ev_func
&& e->e.expr.type->type == ev_func)) {
return def_a;
}
def_b = &def_void;

View file

@ -2302,6 +2302,7 @@ cast_expr (type_t *type, expr_t *e)
e_type = get_type (e);
if (!(type->type == ev_pointer && e_type->type == ev_pointer)
&& !(type->type == ev_func && e_type->type == ev_func)
&& !(((type == &type_integer || type == &type_uinteger)
&& e_type == &type_float)
|| (type == &type_float

View file

@ -174,7 +174,7 @@ expr_t *argv_expr (void);
%type <methodlist> methodprotolist methodprotolist2
%type <type> ivar_decl_list
%expect 3
%expect 4
%{
@ -816,7 +816,7 @@ unary_expr
| '~' cast_expr %prec UNARY { $$ = unary_expr ('~', $2); }
| '&' cast_expr %prec UNARY { $$ = address_expr ($2, 0, 0); }
| SIZEOF unary_expr %prec UNARY { $$ = sizeof_expr ($2, 0); }
| SIZEOF '(' non_field_type ')' %prec HYPERUNARY { $$ = sizeof_expr (0, $3); }
| SIZEOF '(' type ')' %prec HYPERUNARY { $$ = sizeof_expr (0, $3); }
;
primary
@ -838,7 +838,7 @@ primary
cast_expr
: unary_expr
| '(' non_field_type ')' cast_expr %prec UNARY { $$ = cast_expr ($2, $4); }
| '(' type ')' cast_expr %prec UNARY { $$ = cast_expr ($2, $4); }
;
expr