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 <noreply+kokoro@google.com> Maintainer: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
This commit is contained in:
@@ -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__
|
||||
|
||||
Reference in New Issue
Block a user