This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 1/7] Introduce ATTRIBUTE_UNUSED_RESULT and use it
- From: Tom Tromey <tromey at adacore dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at adacore dot com>
- Date: Wed, 27 Feb 2019 15:18:08 -0700
- Subject: [PATCH 1/7] Introduce ATTRIBUTE_UNUSED_RESULT and use it
- References: <20190227221814.17661-1-tromey@adacore.com>
This introduces the new ATTRIBUTE_UNUSED_RESULT define, and applies it
to gdb_argv::release.
gdb/ChangeLog
2019-02-27 Tom Tromey <tromey@adacore.com>
* utils.h (class gdb_argv) <release>: Add
ATTRIBUTE_UNUSED_RESULT.
* common/common-defs.h (ATTRIBUTE_UNUSED_RESULT): Define.
---
gdb/ChangeLog | 6 ++++++
gdb/common/common-defs.h | 6 ++++++
gdb/utils.h | 2 +-
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h
index 732693d65cc..6b1f004ab1b 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 896feb973c9..9dbd6386c68 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;
--
2.20.1