mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-07 16:31:32 +00:00
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:
parent
a3c1f339fc
commit
7209c61912
2 changed files with 7 additions and 2 deletions
|
@ -368,8 +368,9 @@ initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (local_expr) {
|
if (local_expr) {
|
||||||
append_expr (local_expr,
|
init = assign_expr (new_symbol_expr (sym), init);
|
||||||
assign_expr (new_symbol_expr (sym), init));
|
// fold_constants takes care of int/float conversions
|
||||||
|
append_expr (local_expr, fold_constants (init));
|
||||||
} else {
|
} else {
|
||||||
if (init->type != ex_value) { //FIXME enum etc
|
if (init->type != ex_value) { //FIXME enum etc
|
||||||
error (0, "non-constant initializier");
|
error (0, "non-constant initializier");
|
||||||
|
|
4
tools/qfcc/test/int-float.r
Normal file
4
tools/qfcc/test/int-float.r
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
void foo (void)
|
||||||
|
{
|
||||||
|
local float x = 0;
|
||||||
|
}
|
Loading…
Reference in a new issue