mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
[qfcc] Skip over aliases when checking for blocks
This fixes the double call to [super init] as tested by ifsuper.r.
This commit is contained in:
parent
76740d213e
commit
5b202a1733
1 changed files with 17 additions and 6 deletions
|
@ -243,23 +243,34 @@ bool_expr (int op, expr_t *label, expr_t *e1, expr_t *e2)
|
||||||
internal_error (e1, 0);
|
internal_error (e1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __attribute__((pure))
|
||||||
|
has_block_expr (expr_t *e)
|
||||||
|
{
|
||||||
|
while (e->type == ex_alias) {
|
||||||
|
e = e->e.alias.expr;
|
||||||
|
}
|
||||||
|
return e->type == ex_block;
|
||||||
|
}
|
||||||
|
|
||||||
expr_t *
|
expr_t *
|
||||||
convert_bool (expr_t *e, int block)
|
convert_bool (expr_t *e, int block)
|
||||||
{
|
{
|
||||||
expr_t *b;
|
expr_t *b;
|
||||||
|
|
||||||
if (e->type == ex_assign) {
|
if (e->type == ex_assign) {
|
||||||
expr_t *src;
|
expr_t *tst;
|
||||||
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");
|
||||||
src = e->e.assign.src;
|
tst = e->e.assign.src;
|
||||||
if (src->type == ex_block) {
|
if (has_block_expr (tst) && has_block_expr (e->e.assign.dst)) {
|
||||||
src = new_temp_def_expr (get_type (src));
|
tst = new_temp_def_expr (get_type (tst));
|
||||||
e = new_assign_expr (e->e.assign.dst,
|
e = new_assign_expr (e->e.assign.dst,
|
||||||
assign_expr (src, e->e.assign.src));
|
assign_expr (tst, e->e.assign.src));
|
||||||
|
} else if (has_block_expr (tst)) {
|
||||||
|
tst = e->e.assign.dst;
|
||||||
}
|
}
|
||||||
b = convert_bool (src, 1);
|
b = convert_bool (tst, 1);
|
||||||
if (b->type == ex_error)
|
if (b->type == ex_error)
|
||||||
return b;
|
return b;
|
||||||
// insert the assignment into the bool's block
|
// insert the assignment into the bool's block
|
||||||
|
|
Loading…
Reference in a new issue