mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-06-04 10:30:52 +00:00
[qfcc] Emit statements for expressions only once
The switch to using expression dags instead of trees meant that the statement generator could traverse sub-expressions multiple times. This is inefficient but usually ok if there are no side effects. However, side effects and branches (usually from ?:, due to labels) break: side effects happen more than once, and labels get emitted multiple times resulting in orphaned statement blocks (and, in the end, uninitialized temporaries).
This commit is contained in:
parent
701b0f3992
commit
cf756eb1a0
2 changed files with 8 additions and 1 deletions
|
@ -2046,7 +2046,13 @@ statement_subexpr (sblock_t *sblock, const expr_t *e, operand_t **op)
|
|||
internal_error (e, "unexpected sub-expression type: %s",
|
||||
expr_names[e->type]);
|
||||
|
||||
sblock = sfuncs[e->type] (sblock, e, op);
|
||||
if (e->op) {
|
||||
*op = e->op;
|
||||
} else {
|
||||
sblock = sfuncs[e->type] (sblock, e, op);
|
||||
//FIXME const cast (store elsewhere)
|
||||
((expr_t *) e)->op = *op;
|
||||
}
|
||||
return sblock;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue