https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44677

--- Comment #21 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 61171
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61171&action=edit
gcc16-pr44677-wip.patch

So, I tried to implement this partially, so far in the C FE.
As we've been implementing the current behavior for more than 14 years, I think
users should be able to specify what exactly they want in this area, so the WIP
patch currently has 3 levels, level 1 is what is currently implemented, level 2
doesn't consider pre/post inc/decrements as reads in addition to that and level
3 in addition doesn't consider x += y as read of x unless x is referenced from
inside of y.  Both of these were pretty simple (of course need testsuite
coverage).  The question is if we could also handle x = x + y or x = y + x
similarly (whether in level 3 or new level 4), there the mark_exp_read already
happens quite early and not sure how hard it would be to have an exception for
the lhs (but only to the outermost operation, perhaps wrapped in ()s, but not
more levels.  And perhaps only if there is no cast needed.

Anyway, I think I should first try to implement what the patch does in C in C++
if it isn't too hard and only then think about further changes.

Reply via email to