[qfcc] Support promotions for struct initializers

This allows the various vector types to be used to initialized
structures and arrays.
This commit is contained in:
Bill Currie 2022-04-29 20:52:57 +09:00
parent 69ce0e952d
commit 8021848b5b

View file

@ -380,10 +380,17 @@ init_elements (struct def_s *def, expr_t *eles)
reloc_def_op (c->e.labelref.label, &dummy); reloc_def_op (c->e.labelref.label, &dummy);
continue; continue;
} else if (c->type == ex_value) { } else if (c->type == ex_value) {
if (is_float (element->type) type_t *ctype = get_type (c);
&& (is_int (get_type (c)) if (ctype != element->type
|| (is_double (get_type (c)) && c->implicit))) { && type_assignable (element->type, ctype)) {
expr_t *n = cast_expr (&type_float, c); if (!c->implicit
&& !type_promotes (element->type, ctype)) {
warning (c, "initialization of %s with %s"
" (use a cast)\n)",
get_type_string (element->type),
get_type_string (ctype));
}
expr_t *n = cast_expr (element->type, c);
n->line = c->line; n->line = c->line;
n->file = c->line; n->file = c->line;
c = n; c = n;