Use PROTOBUF_DEPRECATED instead of PROTOBUF_DEPRECATED_ENUM

pull/12026/head
Yuriy Chernyshov 2 years ago
parent b4370b2e76
commit 536c3c9ff7
  1. 4
      src/google/protobuf/compiler/cpp/enum.cc
  2. 2
      src/google/protobuf/compiler/cpp/helpers.h
  3. 10
      src/google/protobuf/port_def.inc
  4. 1
      src/google/protobuf/port_undef.inc

@ -143,7 +143,7 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) {
.AnnotatedAs(value), .AnnotatedAs(value),
{"kNumber", Int32ToString(value->number())}, {"kNumber", Int32ToString(value->number())},
{"DEPRECATED", value->options().deprecated() {"DEPRECATED", value->options().deprecated()
? "PROTOBUF_DEPRECATED_ENUM" ? "PROTOBUF_DEPRECATED"
: ""}, : ""},
}, },
R"cc( R"cc(
@ -302,7 +302,7 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* p) const {
{ {
Sub("VALUE", EnumValueName(enum_->value(j))).AnnotatedAs(value), Sub("VALUE", EnumValueName(enum_->value(j))).AnnotatedAs(value),
{"DEPRECATED", {"DEPRECATED",
value->options().deprecated() ? "PROTOBUF_DEPRECATED_ENUM" : ""}, value->options().deprecated() ? "PROTOBUF_DEPRECATED" : ""},
}, },
R"cc( R"cc(
$DEPRECATED $static constexpr $Enum_$ $VALUE$ = $Msg_Enum$_$VALUE$; $DEPRECATED $static constexpr $Enum_$ $VALUE$ = $Msg_Enum$_$VALUE$;

@ -82,7 +82,7 @@ inline std::string DeprecatedAttribute(const Options& /* options */,
inline std::string DeprecatedAttribute(const Options& /* options */, inline std::string DeprecatedAttribute(const Options& /* options */,
const EnumValueDescriptor* d) { const EnumValueDescriptor* d) {
return d->options().deprecated() ? "PROTOBUF_DEPRECATED_ENUM " : ""; return d->options().deprecated() ? "PROTOBUF_DEPRECATED " : "";
} }
// Commonly-used separator comments. Thick is a line of '=', thin is a line // Commonly-used separator comments. Thick is a line of '=', thin is a line

@ -386,16 +386,6 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and
# define PROTOBUF_DEPRECATED_MSG(msg) # define PROTOBUF_DEPRECATED_MSG(msg)
#endif #endif
#if defined(PROTOBUF_DEPRECATED_ENUM)
#error PROTOBUF_DEPRECATED_ENUM was previously defined
#endif
#if defined(__clang__) || defined(__GNUC__)
// https://gcc.gnu.org/gcc-6/changes.html
# define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated))
#else
# define PROTOBUF_DEPRECATED_ENUM
#endif
#if defined(__clang__) #if defined(__clang__)
#define PROTOBUF_IGNORE_DEPRECATION_START \ #define PROTOBUF_IGNORE_DEPRECATION_START \
_Pragma("clang diagnostic push") \ _Pragma("clang diagnostic push") \

@ -56,7 +56,6 @@
#undef PROTOBUF_NOINLINE #undef PROTOBUF_NOINLINE
#undef PROTOBUF_SECTION_VARIABLE #undef PROTOBUF_SECTION_VARIABLE
#undef PROTOBUF_DEPRECATED #undef PROTOBUF_DEPRECATED
#undef PROTOBUF_DEPRECATED_ENUM
#undef PROTOBUF_DEPRECATED_MSG #undef PROTOBUF_DEPRECATED_MSG
#undef PROTOBUF_IGNORE_DEPRECATION_START #undef PROTOBUF_IGNORE_DEPRECATION_START
#undef PROTOBUF_IGNORE_DEPRECATION_STOP #undef PROTOBUF_IGNORE_DEPRECATION_STOP

Loading…
Cancel
Save