gfc_conv_expr_val

Paul Brook paul@codesourcery.com
Thu Aug 4 03:41:00 GMT 2005


On Wednesday 03 August 2005 13:38, Feng Wang wrote:
> When tracing a bug, I found some weird codes in gfc_conv_expr_val. This is
> a simple function in trans-expr.c as follows:
>
> void
> gfc_conv_expr_val (gfc_se * se, gfc_expr * expr)
> {
>   tree val;
>
>   gcc_assert (expr->ts.type != BT_CHARACTER);
>   gfc_conv_expr (se, expr);
>   if (se->post.head)
>     {
>       val = gfc_create_var (TREE_TYPE (se->expr), NULL);
>       gfc_add_modify_expr (&se->pre, val, se->expr);
>     }
> }
>
> In the if block, we create a tempary variable and assign an expression to
> it. But obviously we cannot use the variable when leaving the function. I
> don't know the aim of the function since there is no comment on it. If I
> remove the if block, regtest is also successful on ia64-linux-gnu.

There is a comment in trans.h

As this says gfc_conv_expr_val is used when we need to guarantee that the POST 
block is empty. This is used when we are evaluating a scalar quantity, and 
there is no convenient point to insert and cleanup code.
e.g. the condition in an IF statement.

Expressions requiring cleanups are relatively rare, which is probably why it 
has gone unfixed for so long.

I'll fix this and update the documentation.

Paul



More information about the Fortran mailing list