[binutils-gdb] Introduce ATTRIBUTE_UNUSED_RESULT and use it

Tom Tromey tromey@sourceware.org
Tue Mar 5 15:49:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=18cb7c9f3add62ff598f0551a767af8aaa04b07e

commit 18cb7c9f3add62ff598f0551a767af8aaa04b07e
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Feb 26 14:39:01 2019 -0700

    Introduce ATTRIBUTE_UNUSED_RESULT and use it
    
    This introduces the new ATTRIBUTE_UNUSED_RESULT define, and applies it
    to gdb_argv::release.
    
    gdb/ChangeLog
    2019-03-05  Tom Tromey  <tromey@adacore.com>
    
    	* utils.h (class gdb_argv) <release>: Add
    	ATTRIBUTE_UNUSED_RESULT.
    	* common/common-defs.h (ATTRIBUTE_UNUSED_RESULT): Define.

Diff:
---
 gdb/ChangeLog            | 6 ++++++
 gdb/common/common-defs.h | 6 ++++++
 gdb/utils.h              | 2 +-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 65a74cd..fae7ec0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2019-03-05  Tom Tromey  <tromey@adacore.com>
+
+	* utils.h (class gdb_argv) <release>: Add
+	ATTRIBUTE_UNUSED_RESULT.
+	* common/common-defs.h (ATTRIBUTE_UNUSED_RESULT): Define.
+
 2019-03-02  Eli Zaretskii  <eliz@gnu.org>
 
 	* xml-syscall.c (xml_list_syscalls_by_group): Drop 'struct' from
diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h
index 732693d..6b1f004 100644
--- a/gdb/common/common-defs.h
+++ b/gdb/common/common-defs.h
@@ -93,6 +93,12 @@
 #undef ATTRIBUTE_PRINTF
 #define ATTRIBUTE_PRINTF _GL_ATTRIBUTE_FORMAT_PRINTF
 
+#if GCC_VERSION >= 3004
+#define ATTRIBUTE_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
+#else
+#define ATTRIBUTE_UNUSED_RESULT
+#endif
+
 #include "libiberty.h"
 #include "pathmax.h"
 #include "gdb/signals.h"
diff --git a/gdb/utils.h b/gdb/utils.h
index 896feb9..9dbd638 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -188,7 +188,7 @@ public:
   /* Return the underlying array, transferring ownership to the
      caller.  */
 
-  char **release ()
+  ATTRIBUTE_UNUSED_RESULT char **release ()
   {
     char **result = m_argv;
     m_argv = NULL;



More information about the Gdb-cvs mailing list