mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Fix simple pointer dereferences.
It turns out no code was being generated for x = *y. Ouch. I suspect I need to take a better look at expr_deref at some time in the not too distant future. Conflicts: tools/qfcc/source/statements.c
This commit is contained in:
parent
7a2f7e8982
commit
6ff2644ab5
2 changed files with 26 additions and 0 deletions
|
@ -662,6 +662,18 @@ expr_deref (sblock_t *sblock, expr_t *deref, operand_t **op)
|
||||||
*op = new_operand (op_pointer);
|
*op = new_operand (op_pointer);
|
||||||
(*op)->type = low_level_type (e->e.value.v.pointer.type);
|
(*op)->type = low_level_type (e->e.value.v.pointer.type);
|
||||||
(*op)->o.pointer = &e->e.value.v.pointer;
|
(*op)->o.pointer = &e->e.value.v.pointer;
|
||||||
|
} else {
|
||||||
|
statement_t *s;
|
||||||
|
operand_t *ptr = 0;
|
||||||
|
|
||||||
|
sblock = statement_subexpr (sblock, e, &ptr);
|
||||||
|
if (!*op)
|
||||||
|
*op = temp_operand (type);
|
||||||
|
s = new_statement (".", deref);
|
||||||
|
s->opa = ptr;
|
||||||
|
s->opb = short_operand (0);
|
||||||
|
s->opc = *op;
|
||||||
|
sblock_add_statement (sblock, s);
|
||||||
}
|
}
|
||||||
return sblock;
|
return sblock;
|
||||||
}
|
}
|
||||||
|
|
14
tools/qfcc/test/ptrderef.r
Normal file
14
tools/qfcc/test/ptrderef.r
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
void
|
||||||
|
ptrderef (int *to, int *from)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
|
||||||
|
x = *from;
|
||||||
|
x = *from++;
|
||||||
|
x = *++from;
|
||||||
|
//x = ++*from; FIXME syntax error (valid C)
|
||||||
|
to = from++;
|
||||||
|
to = ++from;
|
||||||
|
*to = *from++;
|
||||||
|
*to = *++from;
|
||||||
|
}
|
Loading…
Reference in a new issue