https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116130
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 58774 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58774&action=edit gcc15-pr116130.patch Untested patch. This doesn't hook it up in the middle-end with the exception of the simple cases (no pointer/reference arguments), which are mapped to ECF_CONST|ECF_LOOPING_CONST_OR_PURE resp. ECF_PURE|ECF_LOOPING_CONST_OR_PURE (unless const or pure attributes are also present). There is no warning for the ?: case, seems we've always behaved that way (though perhaps we want to add some warning for it incrementally). And there is no diagnostics of unsuitable functions. I guess the detection of non-stateless functions with [[unsequenced]] attribute would be easy (but we can't require all calls to be also [[unsequenced]], so it would be just partial warning for one function), but the rest would be pretty hard and not really sure what we could actually diagnose.