aboutsummaryrefslogtreecommitdiff
path: root/gcc/system.h
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-11-11 20:18:06 -0500
committerMarek Polacek <polacek@redhat.com>2020-11-12 11:24:23 -0500
commit876b45db81a708616d70b1ab66b71bd503809c21 (patch)
tree84d073e63e0670d77b3e5b172b1cfd2502070b95 /gcc/system.h
parentf8f575d7593b7a859326d6db477d93946fdbbbfc (diff)
downloadgcc-876b45db81a708616d70b1ab66b71bd503809c21.zip
gcc-876b45db81a708616d70b1ab66b71bd503809c21.tar.gz
gcc-876b45db81a708616d70b1ab66b71bd503809c21.tar.bz2
system: Add WARN_UNUSED_RESULT
I'd like to have the option of marking functions with __attribute__ ((__warn_unused_result__)), so this patch adds a macro. And use it for maybe_wrap_with_location, it's always a bug if the return value is not used, which happened to me and got me confused. gcc/ChangeLog: * system.h (WARN_UNUSED_RESULT): Define for GCC >= 3.4. * tree.h (maybe_wrap_with_location): Add WARN_UNUSED_RESULT.
Diffstat (limited to 'gcc/system.h')
-rw-r--r--gcc/system.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/system.h b/gcc/system.h
index b0f3f1d..6f6ab61 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -789,6 +789,12 @@ extern void fancy_abort (const char *, int, const char *)
#define ALWAYS_INLINE inline
#endif
+#if GCC_VERSION >= 3004
+#define WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
+#else
+#define WARN_UNUSED_RESULT
+#endif
+
/* Use gcc_unreachable() to mark unreachable locations (like an
unreachable default case of a switch. Do not use gcc_assert(0). */
#if (GCC_VERSION >= 4005) && !ENABLE_ASSERT_CHECKING