On 08/06/2017 02:07 PM, Martin Sebor wrote: > The attached patch adds support for a new GCC format specifier, > G, that behaves like %K but accepts a gcall* argument. This > makes it possible to provide inlining context for "artificial" > inline functions like strncpy (with _FORTIFY_SOURCE) in > diagnostics issued from the middle end. > > Martin > > gcc-81117-1.diff > > > PR c/81117 - Improve buffer overflow checking in strncpy > > gcc/ChangeLog: > > PR c/81117 > * tree-diagnostic.c (default_tree_printer): Handle %G. > * tree-pretty-print.h (percent_G_format): Declare new function. > * tree-pretty-print.c (percent_K_format): Define a static overload. > (percent_G_format): New function. > > gcc/c/ChangeLog: > > PR c/81117 > * c-objc-common.c (c_objc_common_init): Handle 'G'. > > gcc/c-family/ChangeLog: > > * c-format.h (T89_G): New macro. > * c-format.c (local_gcall_ptr_node): New variable. > (init_dynamic_diag_info): Initialize it. > > gcc/cp/ChangeLog: > > PR c/81117 > * error.c (cp_printer): Handle 'G'. > > gcc/testsuite/ChangeLog: > > PR c/81117 > * gcc.dg/format/gcc_diag-10.c: Exercise %G. > > diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c > index 52b7e7f..ad58b69 100644 > --- a/gcc/tree-diagnostic.c > +++ b/gcc/tree-diagnostic.c > @@ -275,6 +275,10 @@ default_tree_printer (pretty_printer *pp, text_info > *text, const char *spec, > t = va_arg (*text->args_ptr, tree); > break; > > + case 'G': > + percent_G_format (text); > + return true; > + > case 'K': > percent_K_format (text); > return true; > diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c > index 4d8177c..7c4c805 100644 > --- a/gcc/tree-pretty-print.c > +++ b/gcc/tree-pretty-print.c > @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see > #include "dumpfile.h" > #include "internal-fn.h" > #include "gomp-constants.h" > +#include "gimple.h" This is an indication you're probably putting the 'G' handling in the wrong place. Wouldn't gimple-pretty-print.c be more correct?
That's my only objection to this patch, so if it moves trivially, then it's pre-approved. If it's non-trivial, then we'll want another iteration. jeff