From 3275fa8e4f91a09f24837750aa40cec3b1a1e079 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Fri, 14 May 2021 17:28:36 -0700 Subject: [PATCH] base: Add GEM5_DEPRECATED_ENUM_VAL This deperecation enum works exactly the same way as GEM5_DEPRECATED but will not expand if using GCC <6, as enum value deprecation was only introduced in GCC 6. Change-Id: I64fcaca0d79a353da805642e021ec1cb101cfa0e Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45539 Reviewed-by: Jason Lowe-Power Reviewed-by: Daniel Carvalho Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/base/compiler.hh | 10 ++++++++++ src/sim/aux_vector.hh | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/base/compiler.hh b/src/base/compiler.hh index 4ea0dbb153..ba2a4bc4a8 100644 --- a/src/base/compiler.hh +++ b/src/base/compiler.hh @@ -116,6 +116,16 @@ // Mark a c++ declaration as deprecated, with a message explaining what to do // to update to a non-deprecated alternative. # define GEM5_DEPRECATED(message) [[gnu::deprecated(message)]] +// Mark a C++ emum value as deprecated, with a message explaining what to do +// to update to a non-deprecated alternative. This wraps GEM5_DEPRECATED but +// is guarded by a preprocessor if directive to ensure it is not included +// when compiled in GCC < 6, as deprecation of enum values was introduced in +// GCC 6. All supported clang compilers allow enum value deprecation. +# if defined(__clang__) || __GNUC__ >= 6 +# define GEM5_DEPRECATED_ENUM_VAL(message) GEM5_DEPRECATED(message) +# else +# define GEM5_DEPRECATED_ENUM_VAL(message) +# endif // Mark an expression-like macro as deprecated by wrapping it in some code // which declares and uses a deprecated variable with the same name as the // macro. The wrapping macro evaluates to the same thing as the original macro. diff --git a/src/sim/aux_vector.hh b/src/sim/aux_vector.hh index 55a4a05726..30b7777db1 100644 --- a/src/sim/aux_vector.hh +++ b/src/sim/aux_vector.hh @@ -98,8 +98,8 @@ enum Type } // namespace gem5 #define GEM5_DEPRECATE_AT(NAME, name) M5_AT_##NAME \ - GEM5_DEPRECATED("Replace M5_AT_" #NAME " with gem5::auxv::" #name) = \ - gem5::auxv::name + GEM5_DEPRECATED_ENUM_VAL(\ + "Replace M5_AT_" #NAME " with gem5::auxv::" #name) = gem5::auxv::name enum AuxiliaryVectorType { @@ -122,7 +122,7 @@ enum AuxiliaryVectorType GEM5_DEPRECATE_AT(HWCAP, Hwcap), GEM5_DEPRECATE_AT(CLKTCK, Clktck), GEM5_DEPRECATE_AT(SECURE, Secure), - M5_BASE_PLATFORM GEM5_DEPRECATED( + M5_BASE_PLATFORM GEM5_DEPRECATED_ENUM_VAL( "Replace M5_BASE_PLATFORM with gem5::auxv::BasePlatform") = gem5::auxv::BasePlatform, GEM5_DEPRECATE_AT(RANDOM, Random),