[qfcc] Remove rvalue flag from expr_t

It seems it was needed for dealing with the result expression for block
expressions, but it turns out (possibly thanks to dags), that it's easy
to check for the result value and using the appropriate call to emit the
code thus avoiding the non-executable code warning.
This commit is contained in:
Bill Currie 2024-09-13 21:41:40 +09:00
parent 3f66dc1164
commit 4c603c3989
3 changed files with 17 additions and 6 deletions

View file

@ -328,7 +328,6 @@ typedef struct expr_s {
expr_type type; ///< the type of the result of this expression expr_type type; ///< the type of the result of this expression
int printid; ///< avoid duplicate output when printing int printid; ///< avoid duplicate output when printing
unsigned paren:1; ///< the expression is enclosed in () unsigned paren:1; ///< the expression is enclosed in ()
unsigned rvalue:1; ///< the expression is on the right side of =
unsigned implicit:1; ///< don't warn for implicit casts unsigned implicit:1; ///< don't warn for implicit casts
unsigned nodag:1; ///< prevent use of dags for this expression unsigned nodag:1; ///< prevent use of dags for this expression
///< propagates up ///< propagates up

View file

@ -2708,9 +2708,6 @@ return_expr (function_t *f, const expr_t *e)
if (e->type == ex_vector) { if (e->type == ex_vector) {
e = assign_expr (new_temp_def_expr (t), e); e = assign_expr (new_temp_def_expr (t), e);
} }
if (e->type == ex_block) {
((expr_t *) e->block.result)->rvalue = 1;//FIXME
}
return new_return_expr (e); return new_return_expr (e);
} }

View file

@ -1728,12 +1728,27 @@ expr_deref (sblock_t *sblock, const expr_t *deref, operand_t **op)
return sblock; return sblock;
} }
static sblock_t *
expr_slist (sblock_t *sblock, const ex_list_t *slist, const expr_t *result,
operand_t **op)
{
for (auto s = slist->head; s; s = s->next) {
if (s->expr == result) {
sblock = statement_subexpr (sblock, s->expr, op);
} else {
sblock = statement_single (sblock, s->expr);
}
}
return sblock;
}
static sblock_t * static sblock_t *
expr_block (sblock_t *sblock, const expr_t *e, operand_t **op) expr_block (sblock_t *sblock, const expr_t *e, operand_t **op)
{ {
if (!e->block.result) if (!e->block.result)
internal_error (e, "block sub-expression without result"); internal_error (e, "block sub-expression without result");
sblock = statement_slist (sblock, &e->block.list); sblock = expr_slist (sblock, &e->block.list, e->block.result, op);
sblock = statement_subexpr (sblock, e->block.result, op); sblock = statement_subexpr (sblock, e->block.result, op);
return sblock; return sblock;
} }
@ -2389,7 +2404,7 @@ statement_assign (sblock_t *sblock, const expr_t *e)
static sblock_t * static sblock_t *
statement_nonexec (sblock_t *sblock, const expr_t *e) statement_nonexec (sblock_t *sblock, const expr_t *e)
{ {
if (!e->rvalue && options.warnings.executable) if (options.warnings.executable)
warning (e, "Non-executable statement; executing programmer instead."); warning (e, "Non-executable statement; executing programmer instead.");
return sblock; return sblock;
} }