mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
wasn't catching the precedence inversion in (x - x & y) even though it was caught for (x & y - x).
This commit is contained in:
parent
57bd43fc52
commit
5798c9d67a
1 changed files with 24 additions and 0 deletions
|
@ -1421,6 +1421,30 @@ check_precedence (int op, expr_t *e1, expr_t *e2)
|
|||
e1->paren = 1;
|
||||
return binary_expr (e2->e.expr.op, e1, e2->e.expr.e2);
|
||||
}
|
||||
} else if (e1->type == ex_expr && !e1->paren) {
|
||||
if (((op == '&' || op == '|')
|
||||
&& (e1->e.expr.op == '*' || e1->e.expr.op == '/'
|
||||
|| e1->e.expr.op == '+' || e1->e.expr.op == '-'
|
||||
|| is_compare (e1->e.expr.op)))
|
||||
|| (op == '='
|
||||
&& (e1->e.expr.op == OR || e1->e.expr.op == AND))) {
|
||||
notice (e1, "precedence of `%s' and `%s' inverted for "
|
||||
"traditional code", get_op_string (op),
|
||||
get_op_string (e1->e.expr.op));
|
||||
e2 = binary_expr (op, e1->e.expr.e2, e2);
|
||||
e2->paren = 1;
|
||||
return binary_expr (e1->e.expr.op, e1->e.expr.e1, e2);
|
||||
}
|
||||
if (((op == EQ || op == NE) && is_compare (e1->e.expr.op))
|
||||
|| (op == OR && e1->e.expr.op == AND)
|
||||
|| (op == '|' && e1->e.expr.op == '&')) {
|
||||
notice (e2, "precedence of `%s' raised to `%s' for "
|
||||
"traditional code", get_op_string (op),
|
||||
get_op_string (e1->e.expr.op));
|
||||
e2 = binary_expr (op, e1->e.expr.e2, e2);
|
||||
e2->paren = 1;
|
||||
return binary_expr (e1->e.expr.op, e1->e.expr.e1, e2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (e2->type == ex_expr && !e2->paren) {
|
||||
|
|
Loading…
Reference in a new issue