Browse Source

Updated deprecation macros to annotate deprecated code

Adam Cozzette 6 years ago
parent
commit
f4ceaecf68

+ 1 - 0
BUILD

@@ -59,6 +59,7 @@ COPTS = select({
         "-Wno-unused-function",
         "-Wno-unused-function",
         # Prevents ISO C++ const string assignment warnings for pyext sources.
         # Prevents ISO C++ const string assignment warnings for pyext sources.
         "-Wno-write-strings",
         "-Wno-write-strings",
+        "-Wno-deprecated-declarations",
     ],
     ],
 })
 })
 
 

+ 1 - 0
src/google/protobuf/dynamic_message.h

@@ -44,6 +44,7 @@
 
 
 #include <google/protobuf/stubs/common.h>
 #include <google/protobuf/stubs/common.h>
 #include <google/protobuf/message.h>
 #include <google/protobuf/message.h>
+#include <google/protobuf/reflection.h>
 #include <google/protobuf/stubs/mutex.h>
 #include <google/protobuf/stubs/mutex.h>
 #include <google/protobuf/reflection.h>
 #include <google/protobuf/reflection.h>
 #include <google/protobuf/repeated_field.h>
 #include <google/protobuf/repeated_field.h>

+ 9 - 2
src/google/protobuf/port_def.inc

@@ -146,8 +146,15 @@
 #define PROTOBUF_NAMESPACE_CLOSE \
 #define PROTOBUF_NAMESPACE_CLOSE \
   } /* namespace protobuf */     \
   } /* namespace protobuf */     \
   } /* namespace google */
   } /* namespace google */
-#define PROTOBUF_DEPRECATED
-#define PROTOBUF_DEPRECATED_MSG(x)
+
+#if defined(__GNUC__) || defined(__clang__)
+#define PROTOBUF_DEPRECATED __attribute__((deprecated))
+#define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
+#elif defined(_MSC_VER)
+#define PROTOBUF_DEPRECATED __declspec(deprecated)
+#define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
+#endif
+
 #define PROTOBUF_SECTION_VARIABLE(x)
 #define PROTOBUF_SECTION_VARIABLE(x)
 #define PROTOBUF_MUST_USE_RESULT
 #define PROTOBUF_MUST_USE_RESULT
 
 

+ 3 - 2
src/google/protobuf/stubs/port.h

@@ -103,8 +103,9 @@
   #define LIBPROTOC_EXPORT
   #define LIBPROTOC_EXPORT
 #endif
 #endif
 
 
-#define PROTOBUF_RUNTIME_DEPRECATED(message)
-#define GOOGLE_PROTOBUF_RUNTIME_DEPRECATED(message)
+#define PROTOBUF_RUNTIME_DEPRECATED(message) PROTOBUF_DEPRECATED_MSG(message)
+#define GOOGLE_PROTOBUF_RUNTIME_DEPRECATED(message) \
+    PROTOBUF_DEPRECATED_MSG(message)
 
 
 // ===================================================================
 // ===================================================================
 // from google3/base/port.h
 // from google3/base/port.h

+ 1 - 0
src/google/protobuf/text_format.h

@@ -157,6 +157,7 @@ class PROTOBUF_EXPORT TextFormat {
     GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FastFieldValuePrinter);
     GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FastFieldValuePrinter);
   };
   };
 
 
+  // Deprecated: please use FastFieldValuePrinter instead.
   class PROTOBUF_EXPORT FieldValuePrinter {
   class PROTOBUF_EXPORT FieldValuePrinter {
    public:
    public:
     FieldValuePrinter();
     FieldValuePrinter();