mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[qfcc] Support { } as nil in nested initializers
Did top-level earlier, but forgot to add support for deeper nestings.
This commit is contained in:
parent
1250fe7446
commit
07e6baf32f
2 changed files with 21 additions and 5 deletions
|
@ -450,7 +450,10 @@ init_elements (struct def_s *def, expr_t *eles)
|
|||
if (element->expr) {
|
||||
c = constant_expr (element->expr);
|
||||
} else {
|
||||
c = convert_nil (new_nil_expr (), type);
|
||||
c = new_nil_expr ();
|
||||
}
|
||||
if (c->type == ex_nil) {
|
||||
c = convert_nil (c, type);
|
||||
}
|
||||
append_expr (local_expr, assign_expr (unary_expr ('.', ptr), c));
|
||||
}
|
||||
|
|
|
@ -1148,7 +1148,8 @@ opt_initializer
|
|||
|
||||
var_initializer
|
||||
: '=' expr { $$ = $2; }
|
||||
| '=' '{' element_list optional_comma '}' { $$ = $3; }
|
||||
| '=' '{' { $<spec>$ = $<spec>-1; }
|
||||
element_list optional_comma '}' { $$ = $4; }
|
||||
| '=' '{' '}'
|
||||
{
|
||||
if (is_scalar ($<spec>-1.type)) {
|
||||
|
@ -1169,14 +1170,26 @@ element_list
|
|||
$$ = new_block_expr ();
|
||||
append_expr ($$, $1);
|
||||
}
|
||||
| element_list ',' element
|
||||
| element_list ',' {$<spec>$ = $<spec>0; } element
|
||||
{
|
||||
append_expr ($$, $3);
|
||||
append_expr ($$, $4);
|
||||
}
|
||||
;
|
||||
|
||||
element
|
||||
: '{' element_list optional_comma '}' { $$ = $2; }
|
||||
: '{' { $<spec>$ = $<spec>0; }
|
||||
element_list optional_comma '}' { $$ = $3; }
|
||||
| '{' '}'
|
||||
{
|
||||
// FIXME doesn't check the right type (does prove the inherited
|
||||
// attributes have been passed down correctly though). The problem
|
||||
// is that the type of the sub elements needs to be extracted if
|
||||
// possible
|
||||
if (is_scalar ($<spec>0.type)) {
|
||||
error (0, "empty scalar initializer");
|
||||
}
|
||||
$$ = new_nil_expr ();
|
||||
}
|
||||
| expr { $$ = $1; }
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in a new issue