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:
Bill Currie 2012-11-03 20:10:20 +09:00
parent 7a2f7e8982
commit 6ff2644ab5
2 changed files with 26 additions and 0 deletions

View file

@ -662,6 +662,18 @@ expr_deref (sblock_t *sblock, expr_t *deref, operand_t **op)
*op = new_operand (op_pointer);
(*op)->type = low_level_type (e->e.value.v.pointer.type);
(*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;
}

View 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;
}