https://gcc.gnu.org/g:1d5b687946ab6b02ddb66d6ccdf7ac7e50f59802
commit r17-6364-g1d5b687946ab6b02ddb66d6ccdf7ac7e50f59802 Author: Oleg Tolmatcev <[email protected]> Date: Wed Nov 11 20:44:34 2026 +0100 text-art: Fix -Wformat-diag warnings Avoid leading punctuation in pp_printf formats and use a plain string when no formatting is needed. gcc/ChangeLog: * text-art/style.cc (style::color::print_sgr): Include the color selector in the pp_printf format. * text-art/table.cc (selftest::test_spans_3): Disable -Wformat-diag. Signed-off-by: Oleg Tolmatcev <[email protected]> Diff: --- gcc/text-art/style.cc | 13 +++---------- gcc/text-art/table.cc | 8 ++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gcc/text-art/style.cc b/gcc/text-art/style.cc index d3d898ccb6ea..fd5225c2f0eb 100644 --- a/gcc/text-art/style.cc +++ b/gcc/text-art/style.cc @@ -142,21 +142,14 @@ style::color::print_sgr (pretty_printer *pp, case kind::BITS_8: { ensure_separator (pp, need_separator); - if (fg) - pp_string (pp, "38"); - else - pp_string (pp, "48"); - pp_printf (pp, ";5;%i", (int)u.m_8bit); + pp_printf (pp, "%s;5;%i", fg ? "38" : "48", (int)u.m_8bit); } break; case kind::BITS_24: { ensure_separator (pp, need_separator); - if (fg) - pp_string (pp, "38"); - else - pp_string (pp, "48"); - pp_printf (pp, ";2;%i;%i;%i", + pp_printf (pp, "%s;2;%i;%i;%i", + fg ? "38" : "48", (int)u.m_24bit.r, (int)u.m_24bit.g, (int)u.m_24bit.b); diff --git a/gcc/text-art/table.cc b/gcc/text-art/table.cc index 54e28d81e083..c3f6420b8cd9 100644 --- a/gcc/text-art/table.cc +++ b/gcc/text-art/table.cc @@ -972,12 +972,20 @@ test_spans_3 () table.set_cell (c, styled_string ((cppchar_t)str[i])); } +#if __GNUC__ >= 10 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wformat-diag" +#endif table.set_cell_span (table::rect_t (table::coord_t (0, 2), table::size_t (buf_size, 1)), styled_string::from_fmt (sm, nullptr, "'buf' (char[%i])", (int)buf_size)); + +#if __GNUC__ >= 10 +# pragma GCC diagnostic pop +#endif table.set_cell_span (table::rect_t (table::coord_t (buf_size + 1, 2), table::size_t (str_size - buf_size, 1)), styled_string (sm, "overflow"));
