]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix clang build
authorTom Tromey <tromey@adacore.com>
Wed, 27 Mar 2024 13:21:56 +0000 (07:21 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 27 Mar 2024 16:14:49 +0000 (10:14 -0600)
Simon pointed out that commit 818ef5f4 ("Capture warnings when writing
to the index cache") broke the build with clang.  This patch fixes the
breakage.

gdb/utils.h

index d7db1d84e2f159a71bf1a44781956d6718361ce7..875a25831797816009ab94b2d20609146461cbf0 100644 (file)
@@ -444,10 +444,18 @@ struct deferred_warnings
      hook; see scoped_restore_warning_hook.  Note that no locking is
      done, so users have to be careful to only install this into a
      single thread at a time.  */
-  void operator() (const char *format, va_list args) ATTRIBUTE_PRINTF (2, 0)
+  void operator() (const char *format, va_list args)
   {
     string_file msg (m_can_style);
+    /* Clang warns if we add ATTRIBUTE_PRINTF to this method (because
+       the function-view wrapper doesn't also have the attribute), but
+       then warns again if we remove it, because this vprintf call
+       does not use a literal format string.  So, suppress the
+       warnings here.  */
+    DIAGNOSTIC_PUSH
+    DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
     msg.vprintf (format, args);
+    DIAGNOSTIC_POP
     m_warnings.emplace_back (std::move (msg));
   }