mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[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:
parent
69ce0e952d
commit
8021848b5b
1 changed files with 11 additions and 4 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue