On Fri, Aug 09, 2024 at 04:21:14PM +0100, Alex Coplan wrote: > Hmm, good spot, I didn't realise that convert_from_reference could > change the type of the condition like this. > > In that case I suppose the only thing to do is to construct a stack of > ANNOTATE_EXPRs on the way down and re-build the expressions (taking the > type of the inner expression, starting with the cond) on the way back > up.
I think you don't need to rebuild them, just update their types. Something along the lines of for (tree c = cond; c != *condp; c = TREE_OPERAND (c, 0)) { gcc_checking_assert (TREE_CODE (c) == ANNOTATE_EXPR); TREE_TYPE (c) = TREE_TYPE (*condp); } Jakub