I think it would be nice if some C/C++/global maintainer could rubber stamp the following patch.

Otherwise, I think it is trivial, i.e. I think it can be committed in a few days, unless someone has concerns.

This change to gcc/c-family/c-format.cc LGTM from the *gfortran* POV and is trivially copied from gcc_tdiag_char_table or gcc_cdiag_char_table (which both have it).

* * *

Background:

While this is for gcc/c-family/c-format.cc, the 'gcc_gfc_char_table' is for diagnostic for compiling gcc/fortran/, only.

Namely, the gfc_error, gfc_warning etc. functions are annotated by the
format checking attribute:

#define ATTRIBUTE_GCC_GFC(m, n) __attribute__ ((__format__ (__gcc_gfc__, m, n))) ATTRIBUTE_NONNULL(m)

* * *

As gfc_error etc. call the common diagnostic at the end, '%qE', %qD' etc. are already supported.

(As tested manually; it is also used by this patch series of PA.)

But while %qE is already supported, without the 'gcc_gfc_char_table' change, the '__format__ (__gcc_gfc__' check does not recognize it and
yields a -Werror, causing that a bootstrap fails.

Hence, we need this patch …

* * *

Paul-Antoine Arras wrote:
This enables proper warnings for formats like %qD.

gcc/c-family/ChangeLog:

        * c-format.cc (gcc_gfc_char_table): Add formats for tree objects.
---
  gcc/c-family/c-format.cc | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/gcc/c-family/c-format.cc b/gcc/c-family/c-format.cc
index 5bfd2fc4469..f4163c9cbc0 100644
--- a/gcc/c-family/c-format.cc
+++ b/gcc/c-family/c-format.cc
@@ -847,6 +847,10 @@ static const format_char_info gcc_gfc_char_table[] =
    /* This will require a "locus" at runtime.  */
    { "L",   0, STD_C89, { T89_V,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  
BADLEN  }, "", "R", NULL },
+ /* These will require a "tree" at runtime. */
+  { "DFTV", 1, STD_C89, { T89_T,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  
BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "q+", "'",   NULL },
+  { "E",   1, STD_C89, { T89_T,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  
BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "q+", "",   NULL },
+
    /* These will require nothing.  */
    { "<>",0, STD_C89, NOARGUMENTS, "",      "",   NULL },
{ NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL

Reply via email to