On Fri, 12 May 2017, Marek Polacek wrote:

> In the effort of reducing early folding, we should avoid calling c_fully_fold
> blithely, except when needed for e.g. initializers.  This is a teeny tiny step

Note there are several reasons for early folding in the C front end: at 
least (a) cases where logically needed (initializers and other places 
where constants are needed), (b) because warnings need a folded 
expression, (c) when the expression will go somewhere c_fully_fold does 
not recurse inside.  Also (d) convert, at least, folds regardless of 
whether it's actually necessary.

There is a case for avoiding (b) by putting the necessary information in 
the IR so the warnings can happen later from c_fully_fold, though there 
may be other possible approaches.

> @@ -146,8 +140,7 @@ convert (tree type, tree expr)
>  
>      case COMPLEX_TYPE:
>        /* If converting from COMPLEX_TYPE to a different COMPLEX_TYPE
> -      and e is not COMPLEX_EXPR, convert_to_complex uses save_expr,
> -      but for the C FE c_save_expr needs to be called instead.  */
> +      and E is not COMPLEX_EXPR, convert_to_complex uses save_expr.  */
>        if (TREE_CODE (TREE_TYPE (e)) == COMPLEX_TYPE)
>       {
>         if (TREE_CODE (e) != COMPLEX_EXPR)

The point of this comment is to explain why we don't just call 
convert_to_complex here (see PR 47150).  So with your changes it would 
seem appropriate to change c-convert.c back to calling convert_to_complex 
here.

The changes seem otherwise OK.

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to