https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63943
--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Martin Sebor from comment #3) > As for using %K, I mostly agree. I actually have %G in my tree, but my goal > is to get rid of both and replace them with a new warning function like so: > https://gcc.gnu.org/pipermail/gcc-patches/2021-January/563862.html > and replace calls to warning() and warning_at() in the middle end with those > to the new function. This makes it possible to control warnings at any > point in the lining stack and resolves bug like pr98871. That is great. It may be worth CCing David Malcolm, since he is the diagnostics maintainer. A couple of comments: * #include "tree.h" in diagnostic.c is not great. Ideally, diagnostic.c should be independent of trees so that other front-ends can use it without having to use tree. We went through a lot of work to make the core diagnostics independent of any FE or Middle-end and only depend on line-map and options handling. The original plan is to move it to its own library/module, but I guess there has been little progress in the modular GCC. * There is a tree-diagnostic.c. Everything that depends on tree.h should be moved there. (again, if there was a modular GCC, this would be obvious but alas...) * Although it is more work, I think Richard and other middle-end reviewers would be more motivated to accept this if it removed completely percent_K_format. That is, rather than add yet-another-way, completely replaces the old %K with something better. * I don't contribute to GCC anymore, but rather than doing: diag_inlining_context dic (exp); warning (dic, opt, "%qD specified size %E may exceed maximum object size %E", func, bndrng[0], maxobjsize); I'd prefer: warning_at_inlined_context(exp, opt, "%qD specified size %E may exceed maximum object size %E", func, bndrng[0], maxobjsize); This way, I don't need to know about class diag_inlining_context nor about another variable (dic). I just need to know about an alternative warning function and the magic is hidden from me. This function can live in tree-diagnostic.c which contains the tree-specific functions for diagnostics.