diff --git a/tools/qfcc/source/def.c b/tools/qfcc/source/def.c index 18f35cef9..0af87eab7 100644 --- a/tools/qfcc/source/def.c +++ b/tools/qfcc/source/def.c @@ -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"); diff --git a/tools/qfcc/test/int-float.r b/tools/qfcc/test/int-float.r new file mode 100644 index 000000000..6db6eef48 --- /dev/null +++ b/tools/qfcc/test/int-float.r @@ -0,0 +1,4 @@ +void foo (void) +{ + local float x = 0; +}