[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
1 changed files with 11 additions and 4 deletions

View File

@ -380,10 +380,17 @@ init_elements (struct def_s *def, expr_t *eles)
reloc_def_op (c->e.labelref.label, &dummy);
continue;
} else if (c->type == ex_value) {
if (is_float (element->type)
&& (is_int (get_type (c))
|| (is_double (get_type (c)) && c->implicit))) {
expr_t *n = cast_expr (&type_float, c);
type_t *ctype = get_type (c);
if (ctype != element->type
&& type_assignable (element->type, ctype)) {
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->file = c->line;
c = n;