mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
Reimplement assignment as truth value.
The source of the assignment is used as the value to test, and the assignment itself is inserted into the boolean expressions's block. This fixes the inernal error for "if ((x = 0))".
This commit is contained in:
parent
a881fb5f5b
commit
f6c4e06183
1 changed files with 11 additions and 0 deletions
|
@ -1191,6 +1191,17 @@ convert_bool (expr_t *e, int block)
|
||||||
if (!e->paren && options.warnings.precedence)
|
if (!e->paren && options.warnings.precedence)
|
||||||
warning (e, "suggest parentheses around assignment "
|
warning (e, "suggest parentheses around assignment "
|
||||||
"used as truth value");
|
"used as truth value");
|
||||||
|
b = convert_bool (e->e.expr.e2, 1);
|
||||||
|
if (b->type == ex_error)
|
||||||
|
return b;
|
||||||
|
// insert the assignment into the bool's block
|
||||||
|
e->next = b->e.bool.e->e.block.head;
|
||||||
|
b->e.bool.e->e.block.head = e;
|
||||||
|
if (b->e.bool.e->e.block.tail == &b->e.bool.e->e.block.head) {
|
||||||
|
// shouldn't happen, but just in case
|
||||||
|
b->e.bool.e->e.block.tail = &e->next;
|
||||||
|
}
|
||||||
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e->type == ex_uexpr && e->e.expr.op == '!') {
|
if (e->type == ex_uexpr && e->e.expr.op == '!') {
|
||||||
|
|
Loading…
Reference in a new issue