From 9f92e2f28e3f76efdc62900fdac8dfc95dd9f003 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 23 Jul 2021 23:19:33 -0700 Subject: [PATCH] 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 Maintainer: Daniel Carvalho Reviewed-by: Daniel Carvalho --- src/base/compiler.hh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/base/compiler.hh b/src/base/compiler.hh index e13686c98a..335d828020 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 @@ do { GEM5_VAR_USED int i[] = { 0, ((void)(__VA_ARGS__), 0)... }; } while (0) #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__