]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove use of scoped_restore_tmpl from scoped_restore_warning_hook
authorCiaran Woodward <ciaranwoodward@xmos.com>
Tue, 6 Feb 2024 17:56:07 +0000 (17:56 +0000)
committerCiaran Woodward <ciaranwoodward@xmos.com>
Wed, 7 Feb 2024 16:08:04 +0000 (16:08 +0000)
The warning_hook_handler function pointer takes va_list as
an argument, which on some platforms (mingw64) includes some
attributes. Attributes get ignored in template arguments.
This led to the compiler warning:

error: ignoring attributes on template argument 'warning_hook_handler' {aka 'void (*)(const char*, char*)'} [-Werror=ignored-attributes]
  387 |   scoped_restore_tmpl<warning_hook_handler> m_save;
      |                                           ^

By manually implementing the save/restore behaviour, rather
than using the helper template, this warning is fixed.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/utils.c
gdb/utils.h

index 702c3f1582604b60d526599aa23b8224ebcc8a64..a1aeb1025fa0945062c183105987e402b7d17e9e 100644 (file)
@@ -145,8 +145,14 @@ get_warning_hook_handler ()
 
 scoped_restore_warning_hook::scoped_restore_warning_hook
      (warning_hook_handler new_handler)
-       : m_save (make_scoped_restore (&warning_hook, new_handler))
+       : m_save (warning_hook)
 {
+  warning_hook = new_handler;
+}
+
+scoped_restore_warning_hook::~scoped_restore_warning_hook ()
+{
+  warning_hook = m_save;
 }
 
 /* Print a warning message.  The first argument STRING is the warning
index 7487590902a3335a84b08e86159f4f9ec8258239..2acd1fc4624dfc966919eb6fffa50a3245611d23 100644 (file)
@@ -383,8 +383,15 @@ class scoped_restore_warning_hook
 public:
   explicit scoped_restore_warning_hook (warning_hook_handler new_handler);
 
+  ~scoped_restore_warning_hook ();
+
 private:
-  scoped_restore_tmpl<warning_hook_handler> m_save;
+  scoped_restore_warning_hook (const scoped_restore_warning_hook &other)
+    = delete;
+  scoped_restore_warning_hook &operator= (const scoped_restore_warning_hook &)
+    = delete;
+
+  warning_hook_handler m_save;
 };
 
 /* Return the current warning handler.  */