Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/48510 )

Change subject: base: Deprecate the GEM5_NO_DISCARD macro.
......................................................................

base: Deprecate the GEM5_NO_DISCARD macro.

The now standard [[nodiscard]] attribute can be used directly instead.
Unfortunately, I can't think of any way to actually mark the old macro
as deprecated, since it still has to expand to an attribute which
applies to the following function.

Change-Id: Icbbe3e3d182d845f289727724fef080722093683
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48510
Tested-by: kokoro <[email protected]>
Maintainer: Daniel Carvalho <[email protected]>
Reviewed-by: Daniel Carvalho <[email protected]>
---
M src/base/compiler.hh
1 file changed, 5 insertions(+), 9 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/base/compiler.hh b/src/base/compiler.hh
index e13686c..335d828 100644
--- a/src/base/compiler.hh
+++ b/src/base/compiler.hh
@@ -52,15 +52,6 @@
  * Attributes that become standard in later versions of c++.
  */

-// When the return value of a function should not be discarded, mark it with
-// GEM5_NO_DISCARD.
-#if __has_cpp_attribute(nodiscard) // Standard in c++17, with message in c++20.
-#  define GEM5_NO_DISCARD [[nodiscard]]
-#else
-// Not supported, but it's optional so we can just omit it.
-#  define GEM5_NO_DISCARD
-#endif
-
// When a variable may purposefully not be used, for instance if it's only used
 // in debug statements which might be disabled, mark it with GEM5_VAR_USED.
 #if __has_cpp_attribute(maybe_unused) // Standard in c++17.
@@ -193,10 +184,15 @@
 #define M5_FOR_EACH_IN_PACK(...) GEM5_FOR_EACH_IN_PACK(__VA_ARGS__)
 #define M5_CLASS_VAR_USED GEM5_CLASS_VAR_USED

+// Deprecated attributes which warn.
 #define GEM5_FALLTHROUGH GEM5_DEPRECATED_MACRO_STMT(GEM5_FALLTHROUGH,,\
"Please use the [[fallthrough]] attribute directly."); [[fallthrough]]
 #define GEM5_DEPRECATED(message) \
[[deprecated(message " The GEM5_DEPRECATED macro is also deprecated, "\
              "please use the [[deprecated()]] attribute directly.")]]

+// A deprecated attribute which can't be made to warn without possibly breaking
+// existing code.
+#define GEM5_NO_DISCARD [[nodiscard]]
+
 #endif // __BASE_COMPILER_HH__



1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/48510
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Icbbe3e3d182d845f289727724fef080722093683
Gerrit-Change-Number: 48510
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to