> > ? ? ?tem = fold_build2_loc (loc, code, type, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? fold_convert_loc (loc, TREE_TYPE (op0), > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? TREE_OPERAND (arg0, 1)), op1); > > ? ? ?protected_set_expr_location (tem, loc); > > > > When --enable-checking=fold, fold verifies that none of the arguments > > changed, which in this case it obviously does. > > > > Would be ok to allow a TREE_EXP's location to change within fold? ?That is, > > add locus (for TREE_EXP's) to the list of allowed changeable fields in > > fold_checksum_tree()? > > Why? It looks like the above should already take care of the > correct location via passing loc to fold_build2_loc.
The correct location is being passed. The problem is that in the testcase in question, we modify the original statement (with the new locus). Modifying the original statement is a no no in fold_checksum_tree. We have two options: a) Allow locus changes in fold_checksum_tree. b) Fix fold-const throughout to make a copy of the result of fold_build* calls if we're about to change it's location-- in case fold is returning any of the original arguments. IMO (b) is too inefficient when we can easily do (a). Aldy