On Wed, 25 Nov 2015, Jakub Jelinek wrote:

> But finding out if you have an expression on which c_fully_fold has been
> already called or not is non-trivial too.

The rule is that if the C front end needs to fold early for any reason 
(e.g. for warnings) then the result of folding gets wrapped in a 
C_MAYBE_CONST_EXPR as a signal that what's inside there doesn't need 
folding again - or in another kind of tree that also isn't folded inside, 
such as SAVE_EXPR or CALL_EXPR.

> Wonder if we couldn't use some FE specific bit on the SAVE_EXPR to say
> whether c_fully_fold_internal has already processed it or not, and just
> get rid of c_save_expr, in c_fully_fold* recurse into SAVE_EXPRs too, but
> only if that bit is not yet already set, and set it afterwards.

I suppose you could do that, in line with the general principle of 
reducing early folding (as long as you ensure that folding the contents of 
a SAVE_EXPR results in modifying that SAVE_EXPR so that all pointers to it 
stay pointing to the same tree node).

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

Reply via email to