Fix initializing local float variables with an integer constant.

Run the assignment expression through fold_constants to handle any
necessary conversions and error checking.
This commit is contained in:
Bill Currie 2011-03-05 17:23:22 +09:00
parent a3c1f339fc
commit 7209c61912
2 changed files with 7 additions and 2 deletions

View File

@ -368,8 +368,9 @@ initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
return;
}
if (local_expr) {
append_expr (local_expr,
assign_expr (new_symbol_expr (sym), init));
init = assign_expr (new_symbol_expr (sym), init);
// fold_constants takes care of int/float conversions
append_expr (local_expr, fold_constants (init));
} else {
if (init->type != ex_value) { //FIXME enum etc
error (0, "non-constant initializier");

View File

@ -0,0 +1,4 @@
void foo (void)
{
local float x = 0;
}