Mark block expr result as rvalue when used as one

At least for return. There may be other cases that need it, but this
fixes comma-expr.r (minus int->float promotion issues).
This commit is contained in:
Bill Currie 2019-06-09 19:29:21 +09:00
parent d9c9686288
commit e849c2d1ce
3 changed files with 5 additions and 2 deletions

View file

@ -2021,6 +2021,9 @@ return_expr (function_t *f, expr_t *e)
if (e->type == ex_vector) {
e = assign_expr (new_temp_def_expr (t), e);
}
if (e->type == ex_block) {
e->e.block.result->rvalue = 1;
}
return new_unary_expr ('r', e);
}

View file

@ -1351,7 +1351,7 @@ cexpr
{
if ($1->next) {
expr_t *res = $1;
$1 = build_block_expr ($1->next);
$1 = build_block_expr ($1);
$1->e.block.result = res;
}
$$ = $1;

View file

@ -1273,7 +1273,7 @@ statement_uexpr (sblock_t *sblock, expr_t *e)
static sblock_t *
statement_nonexec (sblock_t *sblock, expr_t *e)
{
if (options.warnings.executable)
if (!e->rvalue && options.warnings.executable)
warning (e, "Non-executable statement; executing programmer instead.");
return sblock;
}