mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-31 03:50:36 +00:00
hopefully fix an off-by-1 vararg copy issue
This commit is contained in:
parent
9f06e0e017
commit
a32f59b256
3 changed files with 20 additions and 3 deletions
6
ir.c
6
ir.c
|
@ -3151,14 +3151,14 @@ static bool gen_function_varargs_copy(ir_function *self)
|
|||
stmt.o3.s1 = 0;
|
||||
maxparams = numparams + self->max_varargs;
|
||||
for (i = numparams; i < maxparams; ++i) {
|
||||
if (i <= 8) {
|
||||
if (i < 8) {
|
||||
stmt.o1.u1 = OFS_PARM0 + 3*i;
|
||||
stmt.o2.u1 = ir_value_code_addr(self->locals[i]);
|
||||
code_push_statement(&stmt, self->context.line);
|
||||
continue;
|
||||
}
|
||||
ext = i - 9;
|
||||
if (ext >= vec_size(ir->extparams))
|
||||
ext = i - 8;
|
||||
while (ext >= vec_size(ir->extparams))
|
||||
ir_gen_extparam(ir);
|
||||
|
||||
ep = ir->extparams[ext];
|
||||
|
|
12
tests/varargs2.qc
Normal file
12
tests/varargs2.qc
Normal file
|
@ -0,0 +1,12 @@
|
|||
void past8(float a, float b, float c, float d, ...count)
|
||||
{
|
||||
float i;
|
||||
print("out:");
|
||||
for (i = 0; i < count; ++i)
|
||||
print(" ", ftos(...(i, float)), "");
|
||||
print("\n");
|
||||
}
|
||||
|
||||
void main() {
|
||||
past8(1, 2, 3, 4, 10, 20, 30, 40, 50, 60, 70, 80);
|
||||
}
|
5
tests/varargs2.tmpl
Normal file
5
tests/varargs2.tmpl
Normal file
|
@ -0,0 +1,5 @@
|
|||
I: varargs2.qc
|
||||
D: non-builtin vararg support test 2
|
||||
T: -execute
|
||||
C: -std=fteqcc -fvariadic-args
|
||||
M: out: 10 20 30 40 50 60 70 80
|
Loading…
Reference in a new issue