Fix assigning int to enum or enum to int

Or float, for v6 progs.
This commit is contained in:
Bill Currie 2019-06-10 08:46:40 +09:00
parent 83fb588727
commit 49ed4310fd
2 changed files with 7 additions and 1 deletions

View file

@ -149,7 +149,12 @@ check_types_compatible (expr_t *dst, expr_t *src)
if (type_assignable (dst_type, src_type)) {
if (is_scalar (dst_type) && is_scalar (src_type)) {
// the types are different but cast-compatible
return assign_expr (dst, cast_expr (dst_type, src));
expr_t *new = cast_expr (dst_type, src);
// the cast was a no-op, so the types are compatible at the
// low level (very true for default type <-> enum)
if (new != src) {
return assign_expr (dst, new);
}
}
return 0;
}

View file

@ -7,6 +7,7 @@ int
main()
{
BOOL b;
b = 0;
b = YES;
return !b;
}