mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 12:52:46 +00:00
Avoid testing block expressions in truth assignments.
This fixes the infinite loop in if ((x = self.heat && x)) Really, I think I need to revisit the whole expression tree code. It's proving to be rather fragile.
This commit is contained in:
parent
60af059b6e
commit
79519bc357
1 changed files with 7 additions and 1 deletions
|
@ -1188,10 +1188,16 @@ convert_bool (expr_t *e, int block)
|
|||
expr_t *b;
|
||||
|
||||
if (e->type == ex_expr && (e->e.expr.op == '=' || e->e.expr.op == PAS)) {
|
||||
expr_t *src;
|
||||
if (!e->paren && options.warnings.precedence)
|
||||
warning (e, "suggest parentheses around assignment "
|
||||
"used as truth value");
|
||||
b = convert_bool (e->e.expr.e2, 1);
|
||||
src = e->e.expr.e2;
|
||||
if (src->type == ex_block) {
|
||||
src = new_temp_def_expr (get_type (src));
|
||||
e = assign_expr (e->e.expr.e1, assign_expr (src, e->e.expr.e2));
|
||||
}
|
||||
b = convert_bool (src, 1);
|
||||
if (b->type == ex_error)
|
||||
return b;
|
||||
// insert the assignment into the bool's block
|
||||
|
|
Loading…
Reference in a new issue