Blame SOURCES/attribute_unused-not-diagnostics.patch

7d6eda
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
7d6eda
From: Luis Machado <luis.machado@linaro.org>
7d6eda
Date: Wed, 11 Dec 2019 11:55:49 -0300
7d6eda
Subject: attribute_unused-not-diagnostics.patch
7d6eda
MIME-Version: 1.0
7d6eda
Content-Type: text/plain; charset=UTF-8
7d6eda
Content-Transfer-Encoding: 8bit
7d6eda
7d6eda
;; Fix unused function errors
7d6eda
;; (Luis Machado et al)
7d6eda
7d6eda
    commit 39f34d7b64ee76e07b82a3e57800905d249d8005
7d6eda
7d6eda
    Fix unused function error
7d6eda
7d6eda
    Attempting to build GDB in Ubuntu 16.04.6 LTS on x86_64, I ran into warnings
7d6eda
    that caused the build to fail:
7d6eda
7d6eda
    binutils-gdb/gdb/gdbsupport/safe-strerror.c:44:1: error: ‘char* select_strerror_r(char*, char*)’ defined but not used [-Werror=unused-function]  select_strerror_r (char *res, char *)
7d6eda
7d6eda
    The diagnostic macro DIAGNOSTIC_IGNORE_UNUSED_FUNCTION seems to expand
7d6eda
    correctly to its respective pragma, but this doesn't seem to have an effect on
7d6eda
    the warning. I tried to use the pragma explicitly and got the same result.
7d6eda
7d6eda
    ATTRIBUTE_UNUSED works fine in this case if you put it in both functions,
7d6eda
    which should fix warnings for both gdb and gdbserver builds.
7d6eda
7d6eda
    The compiler version is gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609.
7d6eda
7d6eda
    This is likely the result of PR64079 in GCC, which was fixed by commit
7d6eda
    9e96f1e1b9731c4e1ef4fbbbf0997319973f0537.
7d6eda
7d6eda
    To prevent other developers from attempting to use this macro, only to get
7d6eda
    confused by it not working as expected, it seems better to not define this
7d6eda
    particular macro.
7d6eda
7d6eda
    gdb/ChangeLog:
7d6eda
7d6eda
    2019-12-12  Luis Machado  <luis.machado@linaro.org>
7d6eda
7d6eda
    	* gdbsupport/safe-strerror.c: Don't include diagnostics.h.
7d6eda
    	(select_strerror_r): Use ATTRIBUTE_UNUSED instead of the diagnostics
7d6eda
    	macros.
7d6eda
7d6eda
    include/ChangeLog:
7d6eda
7d6eda
    2019-12-12  Luis Machado  <luis.machado@linaro.org>
7d6eda
7d6eda
    	* diagnostics.h (DIAGNOSTIC_IGNORE_UNUSED_FUNCTION). Remove
7d6eda
    	definitions.
7d6eda
7d6eda
    Change-Id: Iad6123d61d76d111e3ef8d24aa8c60112304c749
7d6eda
7d6eda
diff --git a/gdb/gdbsupport/safe-strerror.c b/gdb/gdbsupport/safe-strerror.c
7d6eda
--- a/gdb/gdbsupport/safe-strerror.c
7d6eda
+++ b/gdb/gdbsupport/safe-strerror.c
7d6eda
@@ -18,7 +18,6 @@
7d6eda
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7d6eda
 
7d6eda
 #include "common-defs.h"
7d6eda
-#include "diagnostics.h"
7d6eda
 #include <string.h>
7d6eda
 
7d6eda
 /* There are two different versions of strerror_r; one is GNU-specific, the
7d6eda
@@ -27,27 +26,20 @@
7d6eda
    to solve this for us because IPA does not use Gnulib but uses this
7d6eda
    function.  */
7d6eda
 
7d6eda
-/* We only ever use one of the two overloads, so suppress the warning for
7d6eda
-   an unused function.  */
7d6eda
-DIAGNOSTIC_PUSH
7d6eda
-DIAGNOSTIC_IGNORE_UNUSED_FUNCTION
7d6eda
-
7d6eda
 /* Called if we have a XSI-compliant strerror_r.  */
7d6eda
-static char *
7d6eda
+ATTRIBUTE_UNUSED static char *
7d6eda
 select_strerror_r (int res, char *buf)
7d6eda
 {
7d6eda
   return res == 0 ? buf : nullptr;
7d6eda
 }
7d6eda
 
7d6eda
 /* Called if we have a GNU strerror_r.  */
7d6eda
-static char *
7d6eda
+ATTRIBUTE_UNUSED static char *
7d6eda
 select_strerror_r (char *res, char *)
7d6eda
 {
7d6eda
   return res;
7d6eda
 }
7d6eda
 
7d6eda
-DIAGNOSTIC_POP
7d6eda
-
7d6eda
 /* Implementation of safe_strerror as defined in common-utils.h.  */
7d6eda
 
7d6eda
 const char *
7d6eda
diff --git a/gdb/gdbsupport/thread-pool.c b/gdb/gdbsupport/thread-pool.c
7d6eda
--- a/gdb/gdbsupport/thread-pool.c
7d6eda
+++ b/gdb/gdbsupport/thread-pool.c
7d6eda
@@ -25,7 +25,6 @@
7d6eda
 #include "gdbsupport/alt-stack.h"
7d6eda
 #include "gdbsupport/block-signals.h"
7d6eda
 #include <algorithm>
7d6eda
-#include "diagnostics.h"
7d6eda
 
7d6eda
 /* On the off chance that we have the pthread library on a Windows
7d6eda
    host, but std::thread is not using it, avoid calling
7d6eda
@@ -40,14 +39,11 @@
7d6eda
 
7d6eda
 #include <pthread.h>
7d6eda
 
7d6eda
-DIAGNOSTIC_PUSH
7d6eda
-DIAGNOSTIC_IGNORE_UNUSED_FUNCTION
7d6eda
-
7d6eda
 /* Handle platform discrepancies in pthread_setname_np: macOS uses a
7d6eda
    single-argument form, while Linux uses a two-argument form.  This
7d6eda
    wrapper handles the difference.  */
7d6eda
 
7d6eda
-static void
7d6eda
+ATTRIBUTE_UNUSED static void
7d6eda
 set_thread_name (int (*set_name) (pthread_t, const char *), const char *name)
7d6eda
 {
7d6eda
   set_name (pthread_self (), name);
7d6eda
@@ -55,14 +51,12 @@ set_thread_name (int (*set_name) (pthread_t, const char *), const char *name)
7d6eda
 
7d6eda
 /* The macOS man page says that pthread_setname_np returns "void", but
7d6eda
    the headers actually declare it returning "int".  */
7d6eda
-static void
7d6eda
+ATTRIBUTE_UNUSED static void
7d6eda
 set_thread_name (int (*set_name) (const char *), const char *name)
7d6eda
 {
7d6eda
   set_name (name);
7d6eda
 }
7d6eda
 
7d6eda
-DIAGNOSTIC_POP
7d6eda
-
7d6eda
 #endif	/* USE_PTHREAD_SETNAME_NP */
7d6eda
 
7d6eda
 namespace gdb
7d6eda
diff --git a/include/diagnostics.h b/include/diagnostics.h
7d6eda
--- a/include/diagnostics.h
7d6eda
+++ b/include/diagnostics.h
7d6eda
@@ -53,8 +53,6 @@
7d6eda
   DIAGNOSTIC_IGNORE ("-Wdeprecated-declarations")
7d6eda
 # define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER \
7d6eda
   DIAGNOSTIC_IGNORE ("-Wdeprecated-register")
7d6eda
-# define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \
7d6eda
-  DIAGNOSTIC_IGNORE ("-Wunused-function")
7d6eda
 # if __has_warning ("-Wenum-compare-switch")
7d6eda
 #  define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES \
7d6eda
    DIAGNOSTIC_IGNORE ("-Wenum-compare-switch")
7d6eda
@@ -65,9 +63,6 @@
7d6eda
 
7d6eda
 #elif defined (__GNUC__) /* GCC */
7d6eda
 
7d6eda
-# define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \
7d6eda
-  DIAGNOSTIC_IGNORE ("-Wunused-function")
7d6eda
-
7d6eda
 # define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \
7d6eda
   DIAGNOSTIC_IGNORE ("-Wstringop-truncation")
7d6eda
 
7d6eda
@@ -88,10 +83,6 @@
7d6eda
 # define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER
7d6eda
 #endif
7d6eda
 
7d6eda
-#ifndef DIAGNOSTIC_IGNORE_UNUSED_FUNCTION
7d6eda
-# define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION
7d6eda
-#endif
7d6eda
-
7d6eda
 #ifndef DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
7d6eda
 # define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
7d6eda
 #endif