From b0980b0e2242f98862ae6e1843e5a8e9868d5e1f Mon Sep 17 00:00:00 2001 From: thakis Date: Fri, 17 Jul 2015 16:27:59 -0700 Subject: [PATCH] Let protobuf's GOOGLE_COMPILE_ASSERT use static_assert. This merges https://github.com/google/protobuf/pull/621 BUG=411648 Review URL: https://codereview.chromium.org/1242603003 Cr-Commit-Position: refs/heads/master@{#339353} --- third_party/protobuf/README.chromium | 2 ++ third_party/protobuf/src/google/protobuf/stubs/common.h | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/third_party/protobuf/README.chromium b/third_party/protobuf/README.chromium index f2e57bd3848dd9..ad655678a3d88e 100644 --- a/third_party/protobuf/README.chromium +++ b/third_party/protobuf/README.chromium @@ -44,3 +44,5 @@ A BUILD.gn file has been added for building with GN. Cherry-pick pherl changes to make protobuf build on VS2015. Cherry-pick c3cb53b (fix "sometimes-uninitialized" warning). + +Cherry-pick https://github.com/google/protobuf/pull/621 diff --git a/third_party/protobuf/src/google/protobuf/stubs/common.h b/third_party/protobuf/src/google/protobuf/stubs/common.h index e9d0e3525569b7..bdb6b522138429 100644 --- a/third_party/protobuf/src/google/protobuf/stubs/common.h +++ b/third_party/protobuf/src/google/protobuf/stubs/common.h @@ -392,11 +392,12 @@ struct CompileAssert { } // namespace internal #undef GOOGLE_COMPILE_ASSERT +#if __cplusplus >= 201103L +#define GOOGLE_COMPILE_ASSERT(expr, msg) static_assert(expr, #msg) +#else #define GOOGLE_COMPILE_ASSERT(expr, msg) \ typedef ::google::protobuf::internal::CompileAssert<(bool(expr))> \ msg[bool(expr) ? 1 : -1] - - // Implementation details of COMPILE_ASSERT: // // - COMPILE_ASSERT works by defining an array type that has -1 @@ -437,6 +438,7 @@ struct CompileAssert { // // This is to avoid running into a bug in MS VC 7.1, which // causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1. +#endif // __cplusplus >= 201103L // =================================================================== // from google3/base/memory/scoped_ptr.h