]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
analyzer: use correct format code for string literal indices [PR110483,PR111802]
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 27 Feb 2024 19:49:42 +0000 (14:49 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 27 Feb 2024 22:17:12 +0000 (17:17 -0500)
On e.g. gcc211 the use of "%li" with unsigned HOST_WIDE_INT led to this warning:
../../src/gcc/analyzer/access-diagram.cc: In member function ‘void ana::string_literal_spatial_item::add_column_for_byte(text_art::table&, const ana::bit_to_table_map&, text_art::style_manager&, ana::byte_offset_t, ana::byte_offset_t, int, int) const’:
../../src/gcc/analyzer/access-diagram.cc:1909:40: warning: format ‘%li’ expects argument of type ‘long int’, but argument 3 has type ‘long long unsigned int’ [-Wformat=]
          byte_idx_within_string.ulow ()));
                                        ^
and to all values being erroneously printed as "0".

Fixed thusly.

gcc/analyzer/ChangeLog:
PR analyzer/110483
PR analyzer/111802
* access-diagram.cc
(string_literal_spatial_item::add_column_for_byte): Use %wu for
printing unsigned HOST_WIDE_INT.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/access-diagram.cc

index 9555ee823931b306e76e6838e250e29c5a86dbae..24d203f9325a1a86b4157ef548d90874c0cd2ea3 100644 (file)
@@ -1905,7 +1905,7 @@ private:
        const table::rect_t idx_table_rect
          = btm.get_table_rect (&m_string_reg, bytes, byte_idx_table_y, 1);
        t.set_cell_span (idx_table_rect,
-                        fmt_styled_string (sm, "[%li]",
+                        fmt_styled_string (sm, "[%wu]",
                                            byte_idx_within_string.ulow ()));
       }